Reading Source File, Rsrc or Font (for each atom) 11
Writing Target File, Rsrc or Font (for each atom) 11
Finalizing 11
Installer Human Interface
Easy Install Interface 12
Using the Target Disk Interface 13
Using the Application Folder Interface 13
Buttons 13
Custom Install Interface 14
Custom Install List 14
Selected Size and Disk Space Available Values 15
Custom Item Information 15
Custom Remove Interface 16
Selecting the Target Application Folder 17
Selecting the System Volume 18
Adding a Splash Screen 19
Providing User Help 20
Selecting an Installer Document 20
Menus 21
Apple Menu 22
Help Menu 22
Application Menu 22
Using the Installer Preference Resource (‘inpr’) 22
Controlling the Recommended Target Selection 23
Specifying Help Pages 23
Allowing Installation onto AppleShare Volumes 24
Installer Preference Resource Reference 24
Resource Description 24
Data Structures 26
Packages and Atoms
About Packages (‘inpk’) 27
Using Packages 27
Using Packages with Easy Install 27
Using Packages with Custom Install and Remove 27
Atom Execution Order 28
Package Reference 28
Package Resource Description 28
Package Comment Resource Description 30
New Package Comment Resource Description 30
Old Package Comment Resource Description 31
About the File Atom 32
Using the File Atom (‘infa’) 32
Comparing Files by Version 32
Using Split Sources with File Atoms 33
Using Atom Extenders with File Atoms 33
Installing a Custom Folder Icon 34
File Atom Reference 34
Resource Description 34
About the Resource Atom (‘inra’) 38
Using the Resource Atom 39
Comparing Files By Version 39
Using Split Sources with Resource Atoms 39
Using Atom Extenders with Resource Atoms 39
Resource Atom Reference 40
Resource Description 40
About the Resource List Atom (‘inr#’) 44
Using the Resource List Atom 44
Referencing Resource Atom Lists from Packages 44
Resource List Atom Reference 44
Resource Description 45
About the Font Atom (‘inff’) 46
Using the Font Atom 46
Auto-Routing Under Pre-7.1 Systems 46
Using Atom Extenders with Font Atoms 47
Font Atom Reference 47
Resource Description 47
About the ResMerge Atom (‘inrm’) 53
Using the ResMerge Atom 53
ResMerge Atom Reference 54
About the Folder Atom (‘infm’) 55
Using the Folder Atom 55
Specifying the Source and Target Folder 56
Installing Folders with Custom Icons 56
Creating Empty Folders with a Folder Atom 56
Folder Atom Reference 56
Using Action Atoms (‘inaa’) 57
Action Atom Reference 57
Resource Description 58
Data Structures 59
Function Interface 59
Parameter Block 59
Using Audit Atoms (‘inat’) 61
Audit Atom Reference 61
Resource Description 61
Using Boot Block Atoms (‘inbb’) 62
Boot Block Atom Reference 62
Resource Description 62
About Atom Extenders (‘inex’) 65
Writing Atom Extenders 66
Creating an ‘inex’ Script Resource 66
Writing a Simple Atom Extender 66
Memory Allocation within Atom Extenders 69
Running within a Sub-Heap 69
Converting Existing Decompression Code 70
Atom Extender Reference 70
Resource Description 70
Data Structures 72
Function Interface 72
Parameter Block 72
About Version Compare Functions (‘invc’) 76
Using Version Compare Functions with File Atoms 76
Using Version Compare Functions with Resource Atoms 77
Version Compare Runtime Environment 77
Version Compare Function Reference 77
Function Interface 77
Parameter Block 78
Resource Description 78
Installer Rules
Frameworks (‘infr’) 79
Global Rule Framework 79
Easy Install Rule Framework 79
Custom Install Rule Framework 80
Rules (‘inrl’) 80
Using Assertions 82
Rule Clause Reference 83
Global Rule Clauses 83
Easy Install Rule Clauses 91
Custom Install Rule Clauses 92
File Specification
About File Specifications 93
Specifying Target Files (‘intf’) 93
Installing into Special Folders 93
Installing into the User-Selected Application Folder 94
Managing Rollbacks on Multiple Target Volumes 94
Installing onto the Installer Volume 95
Setting the Finder flags and Dates 95
Specifying Source Files (‘infs’) 95
Source Disk Search Path 95
File Spec. Reference 96
Resource Descriptions 96
Target File Spec. Resource (‘intf’) 96
Source File Spec Resource (‘infs’) 98
About File Searching (‘insp’) 99
Using File Searching with File and Resource Atoms 99
Using File Searching with Rule Clauses 99
Allowable Installer Functions During File Searching 99
File Searching Reference 100
Data Structures 100
Function Interface 100
Parameter Block 100
Resource Description 101
About the Disk Order Resource (‘indo’) 102
Disk Order Reference 103
Resource Description 103
Installer Functions
About Installer Functions 104
Data I/O Routines 104
Memory Routines 108
Misc. Routines 110
Miscellaneous Features
About Action Handlers 113
Writing an Action Handler 113
Action Handler Runtime Environment 114
Action Handler Reference 114
Data Structures 114
Function Interface 114
Parameter Block 114
Actions 115
Resource Description 117
About the Installer Version Resource (‘invs’) 118
Installer Version Reference 119
Resource Description 119
About the Script Size Resource (‘insz’) 119
Script Size Reference 119
Resource Description 119
About the Script Creation Date Resource (‘incd’) 120
Script Creation Date Reference 120
Resource Description 120
Installation Topics
Installing Desk Accessories 121
Installing into Pre-7.X Systems 121
Installing into System 7.X 122
Glossary
Glossary 123
Scripting Overview
This chapter provides an overview of writing Installer scripts.
Scripting Overview
An Installer script is a list of instructions for the Installer, in the form of resources. These script resources tell the Installer how to perform an Installation. An Installer script is written using the MPW (Macintosh Programmer's Workshop) Rez language, and compiled using the MPW Rez tool. It is expected that Installer scriptwriters are familiar with the Rez language, MPW development system, and the MPW Rez tool.
The script resources can be divided into three main groups: script resources for displaying the interface, script resources for describing what actions to perform during the installation or removal, and independent script resources.
Script Resources for Displaying the Interface
The scriptwriter is responsible for providing a recommended software selection for Easy Install, and an optional list of software choices for Custom Install. Each interface requires the scriptwriter to create instructions (Installer rules) that are evaluated to tell the Installer what to display to the user and what will happen during the installation or removal.
It is useful to think of script resources as working in a hierarchy. At the top of the hierarchy are framework (‘infr’) and rule (‘inrl’) script resources. The Installer uses these resources to examine the environment and make decisions about what to install based on what it has found on the user’s target disk. For example, in System Software, we install different software depending on the type of machine the Installer is running on, the type of target disk the user has chosen, and what has previously been installed. To use these features, the scriptwriter must provide a set of if-then rules to reach the goal of each interface.
Easy Install interface goals:
n Create the recommended software message that will be shown in the Easy Install dialog. This translates into including the proper rule clauses that will display the desired message or error text.
n Tell the Installer what actions to take after the user clicks the Install button. This requires the scriptwriter to add to the list of packages that should be installed.
Custom Install interface goals:
n Specify the software components to be listed in the Custom Install dialog. Each top-level item equates to a package, with possible sub-packages, that the scriptwriter explicitly adds to the list.
Script Resources for Describing Actions
Installer rules specify the actions to be performed by selecting a set of packages (resource type 'inpk'). Packages have names, associated comment resources, and a list that references atoms. Atoms are script resources that describe a specific action to be performed during an installation or removal, such as copy a file or delete a resource.
In addition to atoms, packages may also reference other packages called subpackages. Subpackages are identical to packages and have two main purposes: to provide the hierarchical list shown in the Custom Install dialog and to make scripting simpler.
In the hierarchy of Installer script resources, atoms are at the lowest level. Atoms come in six flavors: File Atoms, Resource Atoms, Font Atoms, ResMerge Atoms, Folder Atoms, Action Atoms, Audit Atoms and Boot Block Atoms (resource types 'infa', 'inra', 'inff’, ‘inrm', ‘infm', 'inaa', 'inat', and 'inbb', respectively). Note that atoms are not visible to the user of the Installer program. All atoms are contained within packages or subpackages.
Independent Script Resources
Seven independent script resources can optionally be added to the script to control miscellaneous Installer actions and interface parts.
Installation Timeline
Many activities occur during an installation or removal. Keeping the order and dependencies straight is a challenge. To help you understand the specific events that happen during an installation, the seven phases are summarized below.
Launching
User opens Installer.
Installer finds and opens script document.
Read ‘insz’ if it exists and create the script’s sub-heap.
Find the Splash Screen PICT.
User reads and dismisses the Splash Screen.
Setup Function is called, if it exists.
Installer Rule Evaluation
Begin execution of Global Rules, then the rules for the current interface mode (Easy or Custom).
Call code resources referenced by CheckUserFunction and CheckRuleFunction rule clauses when, and if, the rule clause is evaluated.
Call File Searching code resources referenced by Target File Specs that are referenced by rule clauses. The code resource is called once for each Target File Spec regardless how many rule clauses reference the Target File Spec.
User sees the Easy, Custom or Remove dialog.
Preflighting
User clicks the Install or Remove button.
Preparing to install dialog appears.
Call File Search code resource for all relevant Target File Specs.
Check each target file, rsrc or font to compute needed space.
Call Version Compare code resource for File Atoms and Rsrc Atoms as necessary.
Verify that no target files match any source files.
Preparation to Install/Remove
Confirm shutting down running applications if live installation or removal.
Status Dialog appears.
Save off original files, as necessary, if disk space available.
Send ‘Initialize’ message to Atom Extenders.
Call ‘before’ Action Atoms.
Dispose of script sub-heap if extra memory is needed.
Delete old files, resources and fonts.
Reading Source File, Rsrc or Font (for each atom)
Open source file.
User sees “Reading…” in Status Dialog.
Send ‘BeforePart’ message to Atom Extender.
If the Atom Extender did not read the data, the Installer reads as much data as possible, placing each chunk into the buffer list. If not enough memory is free to buffer the data, the buffer list is flushed and the data is written to disk.
Close source file, if necessary.
Writing Target File, Rsrc or Font (for each atom)
Open target file.
User sees “Writing…” in Status Dialog.
Write buffered data into target file, rsrc or font resource.
Send ‘AfterPart’ message to Atom Extender.
Close target file, if necessary.
Finalizing
Send ‘Success’ or ‘Cancel ‘ message to Atom Extenders.
Send ‘after’ or ‘cleanUpCancel’ message to ‘after’ Action Atoms.
Successful or error dialog appears. If the user clicks the Continue button then the Installer continues with the next step then begins again with Rule execution.
Create script sub-heap again if we disposed of it earlier.
Installer Human Interface
This chapter describes the human interface aspects of Installer 4.0.
Easy Install Interface
The Easy Install interface now allows user selection of the target application folder and a larger message area. The target selection area is different for scripts requiring selection of an application folder versus selection of a target disk.
Figure 2-1 The Easy Install dialog.
Using the Target Disk Interface
If your product must always be installed into a specific location on the target disk, then you’ll probably want to limit the user to only selecting from the mounted volumes. This is the case for products, such as system software, that need to be installed predominately in the System Folder. Setting the useDiskTargetMode flag in the preference resource tells the Installer to present an interface compatible with the old Installer 3.X.
Clicking Switch Disk cycles through the mounted volumes. Clicking Eject Disk will eject a chosen ejectable disk.
Using the Application Folder Interface
If your script installs a product such as an application which can be placed most anywhere on the user's Macintosh, then you’ll probably want to allow the user to select a target folder. Setting the useFolderTargetMode flag in the preference resource tells the Installer to present an interface to the user for selecting the target folder in both the Easy Install and Custom Install dialogs. This interface is shown in Figure 2-2.
Much like the current special-xxxx folder path identifier, the new folder-user folder path identifier will be the folder path selected by the user. When the user clicks the Select Folder button a modified standard file dialog appears to allow selection of a new or existing folder. This dialog is discussed in the section “Using the Select Folder Dialog”.
Figure 2-2 The interface for selecting an application folder.
The icon and name for the selected folder depends on the folder chosen by the user:
n If a folder is selected, the folder’s icon will appear with the folder's name on the first line and “on the disk “Macintosh HD”” on the second line.
n If the root level of a volume is selected, the volume’s icon and name will appear.
A default target folder is always recommended to the user when first launching the Installer. The scriptwriter can optionally override the Installer’s suggested default folder using the preference resource.
Buttons
Buttons and their actions:
n Install (or Remove) — Starts the installation or removal. The button is enabled in Easy Install if there was not an error preventing the installation from beginning. In Custom Install and Custom Remove, the button is enabled only if one or more items are selected from the list.
n Quit — Quits the Installer application.
n Help — Opens a the Help dialog. The Help dialog is explained in section “Providing User Help”.
n Switch Disk — Changes the currently selected target disk to the next disk in the volume list. If no other volumes are available to choose from, this button is dimmed. This button is only shown when using the target disk interface mode.
n Eject Disk — Ejects the currently selected target disk. The button is dimmed if the current volume cannot be ejected. This button is only visible when using the target disk interface mode.
n Select Folder — Opens the folder selection dialog. The folder selection dialog is explained in section “Selecting the Target Application Folder”. If the scriptwriter has enabled this feature, and the Option Key is down, the button text changes to “System Disk” and opens the system volume selection dialog. The system volume selection dialog is explained in section “Selecting the System Volume”. This button is only visible when using the application folder interface mode.
Custom Install Interface
The Custom Install dialog can provide experienced users with the flexibility needed to create customized installations of your product.
Figure 2-3 The Custom Install dialog
Custom Install List
Hierarchical custom items allow many opportunities to provide specific choices without cluttering the list or confusing novice users. Users click on the familiar checkbox to select and deselect items in the custom list. Selection rules apply to the relationship between parent and child items:
n When the user selects/deselects an open parent item, all children are shown selected/deselected as well. This helps the user understand the relationship between the parent and child items. Selecting a parent is equal to selecting all the parent’s children and vice versa.
n If the user opens an unselected parent item and begins to select child items, the parent item is displayed with a mixed-state checkbox. A parent item becomes selected if all child items are selected. If all child items are unselected the parent item is displayed unselected. A parent item is displayed as a mixed-state checkbox if a child (which is also a parent item) is displaying a mixed-state checkbox.
Selected Size and Disk Space Available Values
Two additional information fields show the total size of the currently selected custom items and the disk space available on the selected target disk. The size information is very handy for users choosing which software options to install. The scriptwriter will have the option to show or hide these fields using a flag in the preference resource.
NOTE
The Installer only uses the leaf package sizes of the selected custom items to calculate the selected size value. For packages that referenece both atoms and sub-packages, it’s best to create another package that contains only the atoms and reference that package in place of the atoms.
For example, if you have this: Use this instead:
u
Custom Item Information
Custom item information can be viewed in a separate info dialog by clicking on the button () to the right of custom item text. The custom item info dialog is shown in Figure 2-4.
Figure 2-4 The Custom Item Info Dialog
Custom Remove Interface
Prior to Installer 4.0, the user had to hold down the option key to enable the remove feature. By selecting the Custom Remove pop-up menu item, the user can go to the Custom Remove window.
Figure 2-5 The Custom Remove dialog
The Custom Remove window layout looks very similar to that of Custom Install. The main difference is that the items in the Custom Install list which are not removable are dimmed, and the Install button is titled “Remove”.
Selecting the Target Application Folder
If the scriptwriter allows the user to select a target folder, a modified Standard File dialog is shown when the user clicks the Select Folder button. The Select Folder dialog is shown in Figure 2-6.
Figure 2-6 The Select Folder dialog
To select a target folder using the Select Folder dialog, the user selects the folder or disk in the list, and then clicks the Select button. If no items are selected, clicking the Select button chooses the folder or disk whose contents are showing in the list. The Open button is enabled whenever a folder, disk or alias is selected in the list. If the folder or disk is not a valid target disk the Select button is disabled, such as for a locked floppy disk or a sever volume.
The Installer always recommends a target application folder to the user when first launching the Installer. The user is shown the contents of the folder when first opening the Select Folder dialog. If the folder does not already exist, the folder is created so the user can either click Cancel or Select and maintain the recommended selection.
NOTE
We suggest that scriptwriters place the application and associated files and folders directly in the recommend target folder. This provides a visual association between the folder in the Installer’s dialog and the application folder of the same name that is created on the hard disk. This also allows an existing application to be updated more easily. u
Selecting the System Volume
Scriptwriters can allow the user to change the recommended system volume when using the application folder interface. A flag in the preference resource determines if this feature is enabled. The Installer initially recommends that system files be installed on the boot volume. The scriptwriter can override this recommendation using the Setup Function described in the section “Using the Installer Preference Resource”.
The user accesses the Select System Volume dialog by holding down the Option key while clicking the Select Folder button. The Select System Volume dialog is shown in Figure 4-6.
Figure 2-7 The Select System Volume dialog
The user can change the currently selected system volume by choosing a different volume from the pop-up menu. Only valid system volumes (those that contain blessed folders) are shown in the menu.
Adding a Splash Screen
The first screen to be displayed when the Installer is launched is found in the script. If you would like to provide your own splash screen, simply include a 'PICT' resource named “Splash Screen” with a resource ID greater than 1024. The Installer loads the picture from the script and displays it, along with an OK button in the lower right corner to dismiss the splash screen.
You can also have a color splash screen. In addition to the PICT named “Splash Screen”, include a color PICT named “Color Splash Screen”. If the screen has a depth of 4 bits per pixel or greater (16 colors/grays or more) then the Installer will use this PICT instead. Note that you should use the default system color palette for best results.
Create a picture using a drawing or painting program. You will want your picture to be no bigger than 220 (height) by 433 (width) pixels.
The AppleGaramond font is recommended for titles and the help screen fonts included with the SDK for text. Since you cannot be sure your chosen fonts will always be available, it’s best to create a bitmap picture when using fonts other than Geneva 9, 12, Chicago 12 and Monaco 9.
If necessary, convert the picture to a bitmap and copy it into the clipboard. Paste the picture from the clipboard into a newly created ResEdit file. This should create several resources, including a 'PICT' resource. Delete all of the resources you’ve created except the 'PICT'. Save the ResEdit 'PICT' file.
DeRez the ResEdit 'PICT' file using MPW. We use the following DeRez command:
This command appends the Rez definition of the 'PICT' to the end of your script.
Open the script file you just appended the 'PICT' to, go to the end, change the name of the 'PICT' resource (or give it a name if it doesn’t have one) to “Splash Screen”, and ensure that its ID is greater than 1024. Your script now contains the picture in a format Rez can handle when building the script into resource format.
Providing User Help
Clicking the Help button in the Installer window opens the Installer Help window which displays PICTs stored in the Installer or script file. The Installer Help window is shown in Figure 2-8.
Figure 2-8 The Installer Help window
The Installer ships with several simple help screens, but you can override specific default screens and add to the default help pages. The Preference Resource contains a list of the help pages and is discussed in the section “Using the Installer Preference Resource”.
NOTE
Easy-to-read screen fonts, as seen in Figure 2-8, are included in the SDK for your convenience. We suggest that you use these fonts for your help window and splash screen text. u
Selecting an Installer Document
When the user opens the Installer application directly the Installer searches the folder containing the application for one valid document. If no documents or multiple documents are found the Installer displays the dialog shown in Figure 2-9.
Figure 2-9 The Document Not Found Dialog
Clicking Choose displays the standard Open Dialog so the user can choose one Installer document to open. Clicking Cancel in the Open Dialog quits the Installer.
After opening the Installer document the Installer looks for the script version resource (‘invs’) to determine if the version of the Installer application is properly matched to the version of the script. With Installer version 4.0.3 and newer, the Installer will allow the user to open a document with a smaller version than the Installer. If this is the case, the Installer shows the dialog in Figure 2-10.
Figure 2-9 The Early Version Document Dialog
Menus
To allow the user to easily switch processes and to turn balloon help on and off the Help menu and Application menus will be shown under System 7.X. An “About Installer…” item will be shown in the Apple menu.
Apple Menu
The Apple Menu will be shown in full when running under 7.X, but will only contain the “About Installer…” item when running on pre-7.0 systems. Desk Accessories will not be shown in the menu under pre-7.0 systems to restrict DAs from being opened within the Installer.
Figure 2-10 The Apple Menu.
Help Menu
The Help menu will be available to users when running under System 7.X. In addition to the standard two menu items the Installer will add an “Installer Help…” item that opens the Installer’s help window.
Figure 2-11 The Help Menu.
The Help menu is not available when running under pre-7.0 systems.
Application Menu
The Application menu will be available to users when running under System 7.X. Under pre-7.0 systems using MultiFinder the user can switch between applications by clicking on the MultiFinder icon.
Figure 2-12 The Application Menu.
Using the Installer Preference Resource (‘inpr’)
The preference resource allows the scriptwriter to override certain default interface features and actions of the Installer. To utilize this control you must add a preference resource (‘inpr’ ID=300) to the script file. The Installer contains a default ‘inpr’ resource with the ID of 305. The Installer first looks for your ‘inpr’ with the ID 300, and if not found uses its default resource.
The fields and flags in the preference resource control two main areas of the Installer, the recommended target disk/folder selection, and specific human interface elements.
Controlling the Recommended Target Selection
The Installer automatically recommends the target disk, target folder and system disk if the scriptwriter does not provide a preference resource in the script file. If you wish to allow the user to select a target folder then it’s important to at least provide a suggested folder name in your preference resource. To have more control over the recommended target disk, target folder and system disk you can supply a code resource to be called to determine these values. This code resource is referred to as the setup function.
The setup function can recommend the initial values for target disk, target folder and system disk, but the Installer will consider these new values only as suggestions and will not use any value that would be unreasonable. The setup function is called prior to rule execution, or if a splash screen is provided, after the user dismisses the splash screen.
If no setup function is supplied, or a value recommend by the setup function is not valid, the Installer selects the target values using the following strategy:
n Target disk — The Installer first looks for the selected boot disk (value stored in PRAM), then looks at the SCSI ID 0 hard disk, then at the other SCSI disks, then for an old HD 20 hard disk, then any mounted floppies, then the RAM disk, and finally any mounted volume.
n Target application folder — Selects the folder with the name specified in the script file’s preference resource on the root level of the target disk. If the scriptwriter does not provide a preference resource, the preference resource in the Installer file will be used. The current default folder name is “Applications”.
n System disk — Looks first at the boot disk and then the selected boot disk (value stored in PRAM), and if one contains a blessed System Folder and is a valid target volume and not a floppy disk selects that volume. Otherwise, selects the recommended target disk regardless if it contains a blessed System Folder or not.
Specifying Help Pages
The preference resource holds the list of ‘PICT’ resource IDs that specify the pages shown in the help window.
The help window is divided into two vertical sections:
n Graphic Section — This section begins at the left edge of the window and extends to the right edge of the window. Most often you’ll use this section to display a 100 pixel wide color graphic that can be shared among several pages. This strategy saves disk space. If you have simple help pages that are all B/W, then use this section to display a ‘PICT’ resource that is the same width as the help window. Enter zero for the ID to leave this section blank.
n Text Section — This section begins 100 pixels from the left edge of the window and extends to the right edge of the window. This section is used most often to hold text that does not contain color. Enter zero for the ID to leave this section blank.
Two ‘PICT’ resource IDs must be entered for each section, one for display on B/W monitors and the other for monitors displaying 256 or more colors/grays. You may use the same ID for both color and B/W ‘PICT’ IDs. Use the special ID of 0 (zero) to display white space in a section.
The Installer ships with several basic help pages, which you can add to or replace with your own ‘PICT’ resources stored in your script file.
Allowing Installation onto AppleShare Volumes
Using the allowServerAsTarget flag allows the user to select and install onto AppleShare volumes. This flag is an unsupported and untested feature, and is available only as a courtesy to those developers that have hacked previous versions of the Installer to gain this functionality.
s W A R N I N G
Only those scriptwriters that absolutely, positively, must allow their users to install onto AppleShare server volumes should use the allowServerAsTarget flag! You should never try to install anything into the server volume’s System Folder! s
Installer Preference Resource Reference
This section describes the resource description of the ‘inpr’ resource.
Specifies whether the user can choose a target folder, or is limited to choosing a target disk. If the useDiskTargetMode flag is specified, “Switch Disk ” and “Eject Disk” buttons are shown to the user. This is very similar to the old Installer 3.X. If the ‘useFolderTargetMode’ flag is specified, the interface appears with a “Select Folder…” button, instead of the “Switch Disk ” and “Eject Disk” buttons.
Specifies whether the user can change the recommended System disk. If the allowUserToSetSystemDisk flag is specified, the “Select Folder…” button changes to “System Disk…” when the Option Key is depressed. Clicking the “System Disk…” button displays a dialog with a pop-up of the valid System disks.
The allowUserToSetSystemDisk flag is ignored unless the useFolderTargetMode flag is set (see section above). If the useDiskTargetMode flag is used, there is no change to the “SwitchDisk” button when the Option Key is pressed.
Specifies whether the Installer should calculate and show the total size of the currently selected custom items in the Custom and Remove Install interfaces. Since the Installer does not look at the target disk when calculating this value, it will almost always be overestimated. Common packages are only included once in the calculation, but for some scripts this may confuse more than help the user, so use the dontShowSelectedSizeInCustom flag to hide the field. Showing the field is the default action.
noSetupFunctionSupplied/setupFunctionSupplied
Specifies whether the Installer should call the setup function. The type and ID of the setup function code resource must be entered in the setup function fields when the setupFunctionSupplied flag is specified.
dontAllowServerAsTarget/dontAllowServerAsTarget
Specifies whether the Installer should allow the user to install onto AppleShare volumes. WARNING: This flag is an unsupported and untested feature, and is available only as a courtesy to those developers that have hacked previous versions of the Installer to gain this functionality. Only those scriptwriters that absolutely, positively, must allow their users to install onto AppleShare server volumes should use the allowServerAsTarget flag! You should never, ever install anything into the volume’s System Folder!
Field descriptions
Setup Function Code Resource Type
The resource type of the setup function code resource. This field is ignored unless the setupFunctionSupplied flag is specified. The type is usually ‘infn’. (4-bytes)
Setup Function Code Resource ID
The resource ID of the setup function code resource. This field is ignored unless the setupFunctionSupplied flag is specified. (2-bytes)
Help Page Four resource IDs of ‘PICT’ resources that make up one help page. ( Four 2-byte values )
Recommended Target Folder Name
The recommended target folder name. This can be specified at run-time by the scriptwriter in the setup function. As with any file name, the length should be limited to 31 characters, although the Installer will truncate the string if too long. (even-padded Pascal string)
Data Structures
The setup function is a code resource specified in the preference resource that is passed a pointer to a parameter block with information about the Installer’s environment. The entry point of this code resource must have the interface:
Return the result code noErr to have the Installer continue as normal. Return the result code kQuitInstallerNow to force the Installer to quit immediately. Returning any other value will cause an error alert to be display before forcing the Installer to quit.
The parameter block contains the Installer’s suggested target application folder and system disk. The fields in the parameter block can be changed to override the suggested values.
typedef struct {
—> ProcPtr fCallBackProcPtr;
<—> FSSpec fTargetFSSpec;
<—> short fSystemVRefNum;
} EnvironmentSetupPB, *EnvironmentSetupPBPtr;
Field descriptions
fCallBackProcPtr A pointer to the Installer’s dispatch routine. You’ll need to pass this field as a parameter to Installer function glue routines.
fTargetFSSpec Contains the Installer’s suggested target folder information. You can choose to override this suggestion by changing any of the fields in the FSSPec structure. If the useDiskTargetMode flag is specified in the preference resource, only the vRefNum field of fTargetFSSpec is used by the Installer.
fSystemVRefNum The fSystemVRefNum field contains the Installer’s recommended System Folder volume. You can choose to override this suggestion by changing the value passed. This field is ignored when using the useDiskTargetMode flag because the system disk must always be the same as the target disk.
Packages and Atoms
This chapter describes how to use packages and atoms.
About Packages (‘inpk’)
The package is added to the Custom Install list using the AddCustomItem rule clause, and if selected when clicking the Install or Remove button, will be added to the list of packages to install/remove. For an Easy Install, the Installer rule clause AddPackages is used to build up the list of packages that the Installer will use to perform the bulk of the installation.
Using Packages
Packages group atoms to make scripting easier, and to provide the hierarchical list in the Custom Install dialog. The package contains a list of those atoms and other packages that should be installed or removed when the parent package is installed or removed.
Using Packages with Easy Install
One of the goals of the Easy Install rules is to specify the packages that will be installed when the user clicks the Install button. Your Easy Install rules should eventually call the AddPackages rule clause to specify the packages, and ultimately the atoms, to be installed. During an easy installation, the Installer is only concerned with the parts list and the restart flag. The other fields are currently used only in the Custom Install and Remove interface.
Using Packages with Custom Install and Remove
Packages are the foundation for the selectable items the user can choose from in the Custom Install list. Packages are included at the top-level of the list by calling the AddCustomItem rule clause from the Custom Install rules. The specified packages will then be displayed in the list with any nested packages (with their showsOnCustom flag set) shown as selectable sub-packages. It is then up to the user to select the desired packages and click the Install or Remove button.
To aid the user in deciding which items to select, an optional Get Info-style window can be supplied by scriptwriter that provides the icon, total size, version, date and information text. To enable the Get Info window for the item, you need only to create a Package Comment resource (‘icmt’) and reference this from the package.
Atom Execution Order
Once the user clicks the Install or Remove button all specified packages are decomposed into a flat list of atoms. Therefore, the order the Installer executes the atoms is unrelated to their position in the package’s part list. Prior to installation the Installer groups File, Resource, Font, ResMerge, and Folder Atoms based on the source disk they reference. Those atoms that do not need source disks (atoms that delete on install) are grouped together.
For each source disk the Installer executes the atoms in the following order:
n Folder Atoms.
n File Atoms. This allows you to overwrite a file copied with a Folder Atom on the same or previous source disk.
n ResMerge Atoms. This allows you to add or replace additional resources to a file copied on the same or previous source disk.
n Resource Atoms. This allows you to add or replace a resource in a file copied with a Folder, File or ResMerge Atom on the same or previous source disk.
n Font Atoms.
Although the Installer will consistently order the atoms of a specific type, the scriptwriter should never depend on this ordering, except for Action Atoms which are always guaranteed to be ordered by their ‘inaa’ resource ID.
To ensure that the source disks will always be copied in the same order, include a Disk Order resource (‘indo’) in your script.
Package Reference
Package Resource Description
Packages have an 'inpk' resource type. Its template is shown below.
#define PackageFlags \
boolean doesntShowOnCustom, showsOnCustom; \
boolean notRemovable, removable; \
boolean forceRestart, dontForceRestart; \
fill bit[13] /* Reserved */
type 'inpk' {
switch {
case format0:
key integer = 0; /* Package Format version */
PackageFlags; /* Package Flags */
unsigned integer; /* Package Comment Rsrc ID */
unsigned longint; /* Package Size */
EvenPaddedString; /* Package Name */
unsigned integer = $$CountOf(PartsList);
wide array PartsList { /* Parts List */
RsrcType; /* Part Type */
RsrcID; /* Part ID */
};
};
};
Flag descriptions
showsOnCustom/doesntShowOnCustom
Determines if the package should be displayed in the Custom Install list.
removable/notRemovable Determines if the package should be added to the list of packages to be removed when the user has clicked the Remove button. When used with the showsOnCustom flag, determines if the package is selectable in the Custom Remove list. Note that you must also set the deleteWhenRemoving flag on any File, Resource or Font Atoms that are to be removed and you must set the actOnRemove flag in any Action Atoms that are to be called.
To include an package as a selectable item within Custom Remove, it is necessary to also include the package as a selectable item in Custom Install. There is no option to display a package as a selectable item in Custom Remove, but not in Custom Install. You may however choose to do nothing if the package is a selected item within Custom Install, and only act on that selected package during Custom Remove, but this may be confusing to the user.
forceRestart/dontForceRestart
Determines if the Installer should force the user to restart their Macintosh after installing or removing this package when the currently active System Folder is a target. Use the forceRestart flag if the installation requires rebooting to gain functionality, or if the package makes changes to the System file.
Field descriptions
Package Comment Rsrc ID
The resource ID of a package comment resource that displays the package’s size, date, version and a brief description of its contents or what it does. It’s recommended that every package shown in the Custom Install list have a comment resource. If you do not wish to provide a package comment, place a zero in this field. There are two types of comment resources. The first, an ‘icmt’ resource, provides basic information in one resource. The newer ‘inpc’ resource supports the RAM Size field and references a ‘TEXT’ resource that allows up to 32K of information text. (2-bytes)
Package Size The size of all atoms and packages contained in this package. This value is used to display in the comment window as well as provide the estimated selection size provided in Custom Install. The Installer does not use this field to determine the actual disk space requirements of the target hard disk during preflighting. Individual atom sizes are summed to determine if sufficient target disk space is available. (4-bytes)
Package Name The name to be displayed in the Custom Install list. (even-padded Pascal string)
If the Package Name field is a single dash character (-), a gray horizontal line appears in the list of packages. This dash line is similar to the one found for menu resources. This line can be used to separate the items which can be installed into logical groups. If a package is used just for displaying a separation line, all of the other fields are ignored.
Below is a sample gray-line package:
resource 'inpk' (1, "dashed line") {
format0 {
showsOnCustom,
notRemovable,
dontForceRestart,
0, /* Pkg Cmnt Rsrc ID */
0, /* Package size */
"-", /* Package Name */
{} /* empty brackets */
}
};
Part List The type and resource ID of each part contained in this package. (4-bytes + 2-bytes for each list item)
Package Comment Resource Description
Visible packages should reference one of two comment resources to provide additional information to the user about the packages they might want to install or remove. The older ‘icmt’ is supported, but cannot specify the RAM Size field. The new ‘inpc’ comment resource must reference a ‘TEXT’ resource that contains the text to display at the bottom of the package info window. Both templates are described below.
Custom Item Date The release date of the package. The value is specified in seconds since January 1, 1904. The Installer uses the IUDateString toolbox call to get the string to display. See Inside Macintosh Volume II, page 377 and Inside Macintosh Volume I, page 504. (4-bytes)
Custom Item Version The version number of this package. The Installer can decipher two version formats:
Binary coded decimal number. The ones digit is the secondary revision (0 to 9), the tens digit is the primary revision (0 to 9), and all greater digits make up the version number. For example, 100 is version 1.0, 290 is version 2.9, 605 is version 6.0.5, and 5704 is version 57.0.4. The Installer knows this format because it will always be less than 10000. (4-bytes)
‘vers’ resource hexadecimal number. See the definition of ‘Version’ in the “InstallerTypes.r” file. (4-bytes)
Custom Item RAM Requirements
The estimated RAM needs of this package. The Installer displays this value in the package information window. (4-bytes)
Custom Item Icon ID The ID of the appropriate ICON, ICN#, icl4 and/or icl8 resources. The ID must be 1024 or greater (IDs below this range are reserved). If the script contains these icons, the appropriate one is displayed in the upper left corner of the package information window. (2-bytes)
Custom Item Description
The ID of a ‘TEXT’ resource containing the text to appear in the comment section of the package information window. It should describe the package and provide any information that will help the user decide if installing or removing the package is appropriate. Styled text is not currently supported. (2-bytes)
Old Package Comment Resource Description
type 'icmt' {
unsigned hex longint; /* Release Date */
unsigned hex longint; /* Version Number*/
RsrcID; /* Icon ID */
EvenPaddedString; /* Package Comment Text */
};
Field descriptions
Release Date The release date of the package. The value is specified in seconds since January 1, 1904. The Installer uses the IUDateString toolbox call to get the string to display. See Inside Macintosh Volume II, page 377 and Inside Macintosh Volume I, page 504. (4-bytes)
Version Number The version number of this package. The Installer can decipher two version formats:
Binary coded decimal number. The ones digit is the secondary revision (0 to 9), the tens digit is the primary revision (0 to 9), and all greater digits make up the version number. For example, 100 is version 1.0, 290 is version 2.9, 605 is version 6.0.5, and 5704 is version 57.0.4. The Installer knows this format because it will always be less than 10000. (4-bytes)
‘vers’ resource hexadecimal number. See the definition of ‘Version’ in the “InstallerTypes.r” file. (4-bytes)
Icon ID The ID of the appropriate ICON, ICN#, icl4 and/or icl8 resources. The ID must be 1024 or greater (IDs below this range are reserved). If the script contains these icons, the appropriate one is displayed in the upper left corner of the Package Comment window. (2-bytes)
Package Comment Text The text which appears in the comment section of the Package Comment. It should describe the package and provide any information that will help the user decide if installing or removing the package is appropriate. (even-padded Pascal string)
About the File Atom
The File Atom should be used to copy or delete one or both forks of a file. Two versions of the File Atom script resource are understood by Installer 4.0, but it is recommended that you use format version 1.
The File Atom provides the following major features for copying or deleting files:
n Ability to update a file only if it already exists.
n Ability to preserve an existing file.
n Ability to preserve a newer file based on its creation date, ‘vers’ 1 resource or custom code you write.
n Decompression of a file during installation.
n Automatically unlock the file before replacing or deleting, and/or lock the file when the installation is finished.
n Install a file that has been split among multiple source disks.
If you are simply copying hundreds of uncompressed files and do not wish to create separate Files Atoms for each, you might be able to use a Folder Atom instead.
Using the File Atom (‘infa’)
The new version of the File Atom provides for large source files to be split across installation disks, then joined into one file on the target disk during the installation. In addition, compressed source files can be decompressed during the installation using an Atom Extender.
Comparing Files by Version
Two new fields in the File Atom allow the scriptwriter to compare the source and target file using their version number, instead of only using their creation date. The first field holds the source file’s version number, and the second field holds the resource ID of a new Version Compare (‘invc’) script resource. The Version Compare script resource allows the scriptwriter to call a code resource that calculates the version number of the target file.
To compare the newness of the target and source using the old creation date method, use the useSrcCrDateToCompare flag. To compare using the version number in the target’s ‘vers’ ID=1 resource then use the useVersProcToCompare flag and place a 0 (zero) in the Version Compare Rsrc ID field. If the version number is stored somewhere besides the ‘vers’ ID=1 resource then you’ll need to create and attach a Version Compare script resource to the File Atom.
Using either the useSrcCrDateToCompare or useVersProcToCompare flag presents the identical interface to the user if the source file is older than the target file. See the description of the leaveAloneIfNewer flag in the “File Atom Reference” section.
Using Split Sources with File Atoms
The new ‘infa’ script resource contains a source list that holds zero or more references to source files. If the original source file must be split into smaller files, an entry for each split source piece should be placed into the source list. Each entry contains information about the location of the source file (‘infs’ ID), the target size of the resource fork piece and the target size of the data fork piece.
Each target size field must contain the exact size the source piece will appear in the target file. If the piece is being decompressed with an Atom Extender during installation, then this field must contain the uncompressed size of the piece. If only one fork is requested to be copied, the target size field of the other fork is ignored. Place a zero in a fork’s target size field if the fork contains no data.
NOTE
The order of the entries in the source list is important. Each piece will be written to the target file in the same order as it appears in the list. u
Using Atom Extenders with File Atoms
Using Atom Extenders with the new File Atom (Format 1) allows scriptwriters to easily decompress files that have been compressed on the source installation disk. Attach the Atom Extender to the File Atom file by entering the ID of the ‘inex’ script resource into the appropriate field in the ‘infa’. The code resource referenced from the ‘inex’ script resource will be called at the desired point in the installation so it can read the compressed file data, decompress the data, then write it to the target file.
NOTE
You should never create a source file that has a compressed resource fork, because any attempt to access the resource fork by the Finder or other application may crash the Macintosh. The rsrcForkInRsrcFork/rsrcForkInDataFork flag has been added to designate where the resource fork is stored. Use the rsrcForkInDataFork flag when copying a compressed resource fork that is stored in the data fork of the source file. Use the rsrcForkInRsrcFork flag when copying a non-compressed resource fork. u
When the Installer is preparing to install, each File Atom is expanded into one or more parts. As each part is installed, the Atom Extender attached to the original File Atom will be called for each part. When only one source file is specified there is one part for each fork being copied. When split source pieces are specified there is one part for each fork being copied from each piece.
The goal of the new File Atom and Atom Extender is to provide compatibility with most popular compressed source file configurations. Several configurations are listed below.
n The simplest source file configuration is for each compressed fork to be placed into the data fork of two separate files. The Installer will call the Atom Extender separately for each fork.
n Another source file configuration places both forks into the same data fork of a source file, with a header describing the format of the data. The Atom Extender will be called once for each fork copied, but will be responsible for finding, reading and writing the correct data for the specified fork. The Atom Extender parameter block will provide information about which fork is being copied.
n An “Archived” source file configuration contains multiple compressed files (and forks) in one source file. One File Atom must be created for each target file being copied, with each referring to the same source file (‘infs’). The Atom Extender parameter block will contain information about the current file (and fork) being copied, with which the Atom Extender will find, read, decompress and write the proper target file’s data. Our InstaCompOne Atom Extender is an example of this approach.
For those source configurations that cannot be accommodated by the built-in routines, scriptwriters can use the supplied parameter block to perform the copy by themselves. This strategy should only be taken when absolutely necessary.
Installing a Custom Folder Icon
The File Atom can easily be used to set the custom icon of any folder on the target disk. The Installer notices if the scriptwriter is copying the special invisible “Icon\n” file, and if so automatically sets the userCustomIcon bit on its parent folder.
There are several key points to remember when installing a custom icon:
n Since the Installer does not remove the special “Icon\n” file correctly, use the dontDeleteWhenRemoving flag to prevent its removal.
n It’s polite to preserve an existing custom icon, so use the copyIfUpdate flag.
n The Installer will install the custom icon even if the directory is the root level of the hard disk. We discourage scriptwriters from recommending the root level of the hard disk as the target folder, but user’s can select it if they choose.
File Atom Reference
This section describes the resource description of the ‘infa’ resource, format 1.
integer = $$CountOf (Pieces); /* Number of Source Pieces */
wide array Pieces {
fileSpecID; /* Source File Spec*/
unsigned longInt; /* Target Data Fork Part Size */
unsigned longInt; /* Target Rsrc Fork Part Size */
};
unsigned longint; /* Source Version Number */
rsrcID; /* Version Compare Rsrc ID */
rsrcID; /* Atom Extender Rsrc ID */
evenPaddedString; /* Atom Description */
};
};
Flag Descriptions
deleteWhenRemoving/dontDeleteWhenRemoving
Determines if the file is deleted during a removal. When using the deleteWhenRemoving flag, if the target file exists and the user clicks Remove, the target file is deleted. If the file does not exist on the target disk, this flag is ignored. The file atom must be part of a package that uses the removable flag. Note that of the following File Atom flags, only the rsrcFork/noRsrcFork and dataFork/noDataFork flags have any effect on the removal process.
deleteWhenInstalling/dontDeleteWhenInstalling
Determines if a file is deleted during an installation when using the dontCopy flag. Installer generally ignores this flag when using the copy flag. When using the deleteWhenInstalling flag, after the user clicks Install, the target file is deleted if it exists, otherwise the flag is ignored. The deleteWhenInstalling flag is primarily used for deleting previously installed files that are no longer needed.
copy/dontCopy Determines if the file is copied during an installation. Note that some flags (leaveAloneIfNewer, keepExisting, copyIfUpdate) can prevent copying from happening under the circumstances specified.
dontIgnoreLockedFile/ignoreLockedFile
Determines if an existing locked target file should be automatically unlocked before replacing. Only use the ignoreLockedFile flag if you originally installed the file locked or your software locks the file. Use the dontIgnoreLockedFile flag the majority of times to preserve the user’s control over their Macintosh.
dontSetFileLocked/setFileLocked
Determines if the target file should be locked after copying. Use setFileLocked to request that the target file be locked at the end of the installation.
useSrcCrDateToCompare/useVersProcToCompare
Determines how the Installer will determine if the target file is newer or older than the source file. If using the useSrcCrDateToCompare flag the creation date entered in the Source File Spec is compared with the creation date of the target file. If the useVersProcToCompare flag is used, an optionally supplied version function is called to determine the version number of the target file. See the description of the Version Compare Rsrc ID field.
srcNeedExist/srcNeedNotExist
Determines whether the source file must exist on the source disk. Use srcNeedNotExist if the source file can optionally reside on the source disk. If the file is not found the atom is ignored and the installation continues.
rsrcForkInRsrcFork/rsrcForkInDataFork
Since a compressed resource fork should never be left in the resource fork of the source file, this allows the scriptwriter to easily store the compressed resource fork in the data fork. These flags determine where the resource fork data will be read from when using the ReadSourceData() routine. If the rsrcForkInDataFork flag is specified, the source data will actually be read from the data fork.
leaveAloneIfNewer/updateEvenIfNewer
Determines what action the Installer should take if the target file is newer than the source file that is replacing it. The method the Installer uses to determine the newness of the files is based on the useSrcCrDateToCompare and useVersProcToCompare flags. Use the updateEvenIfNewer flag if the version of this file must be synchronized with specific versions of other files that are part of the installation. The alert displayed to the user depends whether the user is performing an Easy Install or a Custom Install.
Easy Install — If using the leaveAloneIfNewer flag, the user will not be notified and the newer will be preserved. If using the updateEvenIfNewer flag, an alert is shown that has two options: Continue or Cancel. Clicking Cancel will stop the installation, and clicking Continue will replace the newer target file with the older source file.
Custom Install — If using the leaveAloneIfNewer flag, the user will be presented with an alert that provides three choices: Newer, Older or Cancel. If using the updateEvenIfNewer flag, the alert is the same as for an Easy Install.
keepExisting/updateExisting
Allows the scriptwriter to preserve an existing file when using the copy and/or deleteOnInstall flag. This might be the case if you want to preserve a preference file that contains user specific data. Use keepExisting to prevent the Installer from disturbing an existing target file. No copying will occur if the updateExisting flag is used with the copyIfUpdate flag.
copyIfUpdate/copyIfNewOrUpdate
Allows the scriptwriter to update a file only if it already exists when used with the copy flag. Use copyIfUpdate to prevent a new file from being created. If the copyIfUpdate flag is used with the keepExisting flag then no copying will occur.
rsrcFork/noRsrcFork Determines if the resource fork of the file is affected during an installation or removal. Use resourceFork to copy or delete the entire resource fork of the file during an installation, or delete the entire resource fork during a removal. Use noResourceFork to not touch the resource fork of the file.
dataFork/noDataFork Determines if the data fork of the file is affected during an installation or removal. Use dataFork to copy or delete the entire data fork of the file during an installation, or delete the entire data fork during a removal. Use noDataFork to not touch the data fork of the file.
Field Descriptions
Total Target File Size The size in bytes of the file to be installed or deleted. This field is only used by the Installer in figuring the disk size needed for an installation. (4-bytes)
Finder Attribute Flags
These flags determine how Finder displays and manages user interaction with the file. If you are using ScriptCheck 4.0, then this field is updated automatically (see ScriptCheck documentation for handling compressed source files), otherwise you must place the correct value in this field. See Inside Macintoh, Volume VI, pages 9-36 - 9-38 for more information about these flags. (2-bytes)
Source File Spec. Rsrc ID
The resource ID of a Source File Spec. (‘infs’) describing the source file where the data is stored. If you’re just deleting a file and therefore don’t need a source file, enter 0 (zero) in this field. (2-bytes)
Target Data Fork Piece Size
The number of bytes the data fork piece will occupy in the target file. If the data fork is decompressed using an Atom Extender during the installation, then this value should be the original noncompressed size of the source piece. The value is used to compute where multiple pieces are to be written into the final target file, and therefore must be exact. If not copying the data fork, this field is ignored. (4-bytes)
Target Rsrc Fork Piece Size
The number of bytes the resource fork piece will occupy in the target file. If not copying the resource fork, this field is ignored. If the resource fork is decompressed using an Atom Extender during the installation, then this value should be the original noncompressed size of the source piece. The value is used to compute where multiple pieces are to be written into the final target file, and therefore must be exact. (4-bytes)
Source Version Number The version number (BCD format) of the source file when using the useVersProcToCompare flag. See Inside Macintosh: Macintosh Toolbox Essentials, page 7-31 for a description of the version number format. (4-bytes)
Version Compare Rsrc ID The resource ID of a Version Compare (‘invc’) script resource. The resulting version number from the version function will be compared with the Version Number field to determine if the target is newer or older than the source. If the resource ID is 0 (zero) and the useVersProcToCompare flag is used the Installer will default to comparing the Source Version Number field with the version number in the ‘vers’ ID=1 resource contained in the target file. If no ‘vers’ ID=1 resource exists then the target version number is assumed to be 0 (zero). (2-bytes)
Atom Extender Rsrc ID The resource ID of an Atom Extender (‘inex’ script resource). (2-bytes)
File Atom Description The File Atom Description field is an even-padded Pascal string describing the atom. This is used as part of the status dialog. If you do not supply a description the Installer will display “Copying File: [file name]” or “Writing File: [file name].” If you supply a description it will be appended to the string “Copying “ or “Writing “.
About the Resource Atom (‘inra’)
The Resource Atom should be used to copy or delete a single resources in a file. Two versions of the Resource Atom script resource are understood by Installer 4.0, but it is recommended that you use format version 1.
The Resource Atom provides the following major features for copying or deleting files:
n Ability to update a resource only if it already exists.
n Ability to preserve an existing resource.
n Ability to preserve a newer resource based on its version number that is determined by custom code you write.
n Decompression of the resource during installation.
n Installation of a resource that has been split among multiple resources on multiple source disks.
If you must copy all the resources from a single source file and merge them with the target file you may want to consider using the ResMerge Atom.
Using the Resource Atom
Comparing Files By Version
Two new fields in the Resource Atom allow the scriptwriter to compare the source and target resource based on the version number. The first field holds the source file’s version number, and the second field holds the ID of a Version Compare (‘invc’) script resource. The Version Compare script resource allows the scriptwriter to call a code resource that calculates the version number of the target resource.
To compare the version number of the target resource to the source version number entered in the Resource Atom you’ll need to create and attach a Version Compare script resource to the Resource Atom. Since setting and obtaining version number information for an individual resource is not a feature of the Resource Manager, extracting the version number from the target resource depends on how the resource encodes its version number. Most examples of this use a header at the beginning of the resource to hold this type of information.
Using Split Sources with Resource Atoms
The format 1 version of the Resource Atom script resource contains a list of source entries. If the original resource must be split into smaller resource pieces, an entry for each split source piece must be placed into the source list. Each entry contains information about the location of the source file (‘infs’ ID), the source resource type, the source resource ID, the target size of the resource piece, and the source resource name. The target size field must contain the exact size the source piece will appear in the target resource. If the piece is being decompressed with an Atom Extender during installation, this field must contain the original uncompressed size of the piece.
When specifying more than one split resource piece, the Installer joins the pieces into a target resource in the order the sources are specified. Generally, you’ll want to use ‘part’ for the type of source resources that have been split and/or compressed. This prevents resources compressed using third-party schemes from being confused with the original resource, especially when using tools like ResEdit and DeRez.
Using Atom Extenders with Resource Atoms
You’ll use an Atom Extender to decompress a resource that was compressed by you to save space on your source disks. The Resource Atom is expanded into one or more parts that the Atom Extender receives with the kBeforePart and kAfterPart messages. There will be one part for each source resource piece specified in the source list. Since owned resources are always copied whole and are usually relatively small, the owner’s Atom Extender is never called when copying its owned resources.
NOTE
The compressed flag in the resource attributes should NOT be set on any source resource being decompressed using an Atom Extender. This flag is presently reserved for use by Apple Computer, Inc. u
Resource Atom Reference
This section describes the resource description of the ‘inra’ resource, format 1.
integer = $$CountOf (Parts); /* Number of Pieces */
wide array Parts {
fileSpecID; /* Source Piece File Spec */
rsrcType; /* Source Piece Type */
rsrcID; /* Source Piece Rsrc ID */
unsigned longInt; /* Target Piece Size */
evenPaddedString /* Source Piece Rsrc Name */
}
unsigned longint; /* Source Version Number */
rsrcID; /* Version Compare Rsrc ID */
rsrcID; /* Atom Extender Rsrc ID */
evenPaddedString; /* Atom Description */
};
};
Flag Descriptions
deleteWhenRemoving/dontDeleteWhenRemoving
Determines if the resource is deleted during a removal. When using the deleteWhenRemoving flag, if the target resource exists and the user clicks Remove, the target resource is deleted. If the resource does not exist on the target disk, this flag is ignored. Note that the Resource Atom must be part of a package that uses the removable flag.
deleteWhenInstalling/dontDeleteWhenInstalling
Determines if the resource is deleted during an installation when using the dontCopy flag. When using the deleteWhenInstalling flag, after the user clicks Install, the target resource is deleted if it exists, otherwise the flag is ignored. The deleteWhenInstalling flag is primarily used for deleting previously installed resources that are no longer needed. Note that some flags (leaveAloneIfNewer, keepExisting) can prevent deletion from happening under the circumstances specified.
copy/dontCopy Determines if the resource is copied or not during an installation. Note that some flags (leaveAloneIfNewer, keepExisting, copyIfUpdate) can prevent copying from happening under the circumstances specified.
leaveAloneIfNewer/updateEvenIfNewer
Determines what action the Installer should take if the target resource is newer than the source resource that is replacing it. The scriptwriter must write a code resource that determines the version number by referencing the resource ID of a Version Compare (‘invc’) script resource. Use the leaveAloneIfNewer flag to prevent the older source resource from replacing the newer target resource during an installation. Unlike the File Atom, the user is not given a chance to override the result of this flag. Use the updateEvenIfNewer flag if the version of this resource must be synchronized with specific versions of other files or resources that are part of the installation.
tgtRequired/noTgtRequired
The target file for this resource must already exist. If the target file does not exist, the user is warned that a target file is needed. (For example, AppleShare installs resources into the System file, but if there is no system file, the Installer alerts the user, rather than creating a System file which has only the AppleShare resources in it.) When using the noTgtRequired flag and the target file does not exist, the Installer will create one.
keepExisting/updateExisting
Allows the scriptwriter to preserve an existing resource when using the copy and/or deleteOnInstall flag. This might be the case if you want to preserve a preference resource that contains user specific data. Use keepExisting to prevent the Installer from disturbing an existing target resource. No copying will occur if the updateExisting flag is used with the copyIfUpdate flag.
copyIfUpdate/copyIfNewOrUpdate
Allows the scriptwriter to update a resource only if it already exists. Use the copyIfUpdate flag to prevent a new resource from being created. If the copyIfUpdate flag is used with the keepExisting flag then no copying will occur.
ignoreProtection/dontIgnoreProtection
Determines if the user should be alerted if any resource with its protected bit set will be replaced or deleted. When using the ignoreProtection flag the resource is deleted from or updated in the target file even if it is protected in the target file.
srcNeedExist/srcNeedNotExist
Determines whether the source resources must exist on the source disk. Use the srcNeedNotExist flag if the source resources can optionally reside on the source disk. If the source file or source resources are not found, the atom it is ignored and the installation continues normally.
byID/byName Determines how the resource should be found in the source and target files. If using the byID flag the resource is found in the source and target file using only the ID. If you want to require the resource name to match as well then use the nameMustMatch flag. If using the byName flag the resource is found in the source and target file using only the name specified in the Resource Name field. Use the byName flag when installing Desk Accessory resources in pre-7.0 System files.
nameMustMatch/nameNeedNotMatch
Specifies that the resource found in the source file using its ID have the name in the Resource Name field. The resource with the same name and ID in the target file, if any, will be replaced or deleted (if the updateExisting flag is used). This flag is ignored if the byName flag, above, is used. If using the nameNeedNotMatch flag the byID flag must also be used.
Field Descriptions
Total Target Size The size in bytes of the copied target resource and all its owned resources. This field is used only by the Installer in figuring the disk size needed for an installation. (4-bytes)
Target Resource File Spec.
The resource ID of a Target File Spec script resource (‘intf’, or ‘infs’ for pre-4,0 scripts) describing the file on the target disk where the resource will be deleted, created, or updated. (2-bytes)
Target Resource Type The resource type the Installer will use to find or create the resource in the target file. (4-bytes)
Target Resource ID The resource ID the Installer will use to find or create the resource in the target file. If the ID of the resource doesn’t matter and you’re copying using the byName flag (e.g., most Desk Accessories), this field should be 0, in which case the Installer picks an ID for the resource in the target file. (2-bytes)
Target Resource Attributes
The attributes that will be given to the target resource when copying. (2-bytes)
Target Resource Name The name that will be given to the target resource. If this string is empty, the name of the first source resource will be given to the target resource. (even-padded Pascal string)
Source Piece File Spec. The resource ID of a Source File Spec. (‘infs’) describing the source file that holds the resource part. If you’re just deleting a resource and therefore don’t need a source file, leave the source list empty. (2-bytes)
Source Piece Type The resource type of the resource piece being copied. If there is more then one piece, it’s recommended that the type by ‘part’. (4-bytes)
Source Piece ID The resource ID of the resource piece being copied. This field is ignored if the resource piece is being found by name (byName flag is used). (2-bytes)
Target Piece Size The number of bytes the resource piece will occupy in the target file. If the resource will be decompressed using an Atom Extender, then this value should be the noncompressed size of the source piece. This value is used to compute where multiple pieces are to be written in the final target file, and therefore must be exact. (4-bytes)
Source Piece Resource Name
The name of the source resource. This field is only needed when finding the source resource by its resource name (byName flag is used). (even-padded Pascal string)
Source Version Number The version number (BCD format) of the source resource when a Version Compare function is used to calculate the target version number. (4-bytes)
Version Compare Rsrc ID The resource ID of a Version Compare (‘invc’) script resource. The resulting version number from the version function will be compared with the Source Version Number field to determine if the target is newer or older than the source. If this field is 0 (zero) then the target version number is assumed to be 0 (zero). (2-bytes)
Atom Extender Rsrc ID The resource ID of an Atom Extender (‘inex’) script resource. This Atom Extender will be called during copying of each resource part. (2-bytes)
When using InstaCompOne compression enter a value of 241 here.
Resource Atom Description
The Resource Atom Description field is an even-padded Pascal string describing the atom. This is used as part of the status dialog. If you do not supply a description the Installer will display “Building File: [file name]” or “Writing File: [file name].” If you supply a description it will be appended to the string “Building “ or “Writing “.
About the Resource List Atom (‘inr#’)
The Resource List Atom is a unique atom that provides a more compact storage structure with slightly reduced functionality for installing resources. This enables scriptwriters to copy thousands of individual resources without the overhead of thousands of Resource Atom resources in their script file. For installation of less than a 100 resources, most scriptwriters should continue using individual Resource Atoms.
Using the Resource List Atom
The Resource List Atom is actually an array of individual Resource Atom records. The records are of a fixed size, so some options available in format 1 of the Resource Atom are not available in the Resource List Atom.
Use format1 Resource Atoms instead of the Resource List Atom if you need any of the following features:
n Find a source resource based on its name.
n Copy a resource that is split across multiple files.
n Specify a target resource name.
n Use with InstaCompOne decompression Atom Extender.
n Change the type or ID during installation. The Resource List Atom requires the target resource type and ID to be the same as the source resource type and ID.
Referencing Resource Atom Lists from Packages
Unlike other atoms, Resource Atom Lists are not referenced using their own atom type (‘inr#’). Instead, packages should reference the atom type ‘inra’ and the ID entered in the Resource ID field of the resource atom record inside the Resource Atom List array. When an ‘inra’ is found referenced from a package, the Installer first looks for a Resource List Atom (‘inr#’) resource, and if not found looks for an actual resource of type ‘inra’ and the specified ID in script file. When the Resource List Atom resource is found, the Installer searches through the list looking for a resource record that matches the requested resource ID. The Resource ID field in the record holds a 2-byte value that you create.
Resource List Atom Reference
This section describes the resource description of the ‘inr#’ resource, format 0.
Resource Description
type 'inr#' {
switch {
case format0:
key integer = 0; /* Resource Atom Format version */
integer = $$CountOf (inraRsrcs); /* Number of inraRsrcs */
wide array inraRsrcs {
integer; /* Resource ID */
resourceAtomFlagsFormat1; /* Resource Atom Flags */
unsigned longInt; /* Total Target Size */
fileSpecID; /* Target File Spec */
fileSpecID; /* Source File Spec */
rsrcType; /* Src/Tgt Rsrc Type */
rsrcID; /* Src/Tgt Rsrc ID */
integer; /* Tgt Rsrc Attributes */
unsigned longint; /* Source Version Number */
rsrcID; /* Version Compare Rsrc ID */
rsrcID; /* Atom Extender ID */
unsigned longInt; /* Target Size of Rsrc */
};
};
};
Flag Descriptions
The flags for the Resource List Atom are identical to format 1 of the Resource Atom. Since there is no source name field in the Resource List Atom you should always use the byID and nameNeedNotMatch flags.
Field Descriptions
Resource ID The ID value that will be used to find this record from the reference in a package. For example, if you choose the ID value of 369, then the reference from a package should have the type ‘inra’ and the ID 369. (4-bytes)
Total Target Size The size, in bytes, of the copied target resource and all its owned resources. This field is only used by the Installer for calculating the disk size needed for an installation. (4-bytes)
Target File Spec. The resource ID of a Target File Spec script resource (‘intf’, or ‘infs’ for pre-4,0 scripts) describing the file on the target disk where the resource will be deleted, created, or updated. (2-bytes)
Source File Spec. The resource ID of a Source File Spec. (‘infs’) describing the source file that holds the source resource. If you’re just deleting a resource and therefore don’t need a source file, place a 0 (zero) in this field. (2-bytes)
Src/Tgt Resource Type The resource type the Installer will use to find the resource in the target and source file. If the resource must be created in the target file it will be given this type. (4-bytes)
Src/Tgt Resource ID The resource ID the Installer will use to find the resource in the target and source file. If the resource must be created in the target file it will be given this ID. (2-bytes)
Target Resource Attributes
The attributes that will be given to the target resource when copying. (2-bytes)
Source Version Number The version number (BCD format) of the source resource when a Version Compare function is used to calculate the target version number. (4-bytes)
Version Compare Rsrc ID The resource ID of a Version Compare (‘invc’) script resource. The resulting version number from the Version Compare function will be compared with the Source Version Number field to determine if the target is newer or older than the source. If this field is 0 (zero) then the target version number is assumed to be 0 (zero). (2-bytes)
Atom Extender Rsrc ID The resource ID of an Atom Extender (‘inex’) script resource. This Atom Extender will be called during copying of each resource. (2-bytes)
Target Size The size in bytes of the copied target resource item. This field is used only by the Installer in figuring the disk size needed for an installation. (4-bytes)
About the Font Atom (‘inff’)
The Font Atom is used to describe a set of font strikes (size/style) from a specified font family which should be copied to or removed from a file. Two versions of the Resource Atom script resource are understood by Installer 4.0, but it is recommended that you use format version 1.
The Font Atom provides the following major features for copying or deleting fonts:
n Ability to preserve an existing font strike.
n Ability to specify an individual strike to copy/delete or simple mode that copies the complete family.
n Support for installing into all versions of System Software with a single Font Atom.
n Decompression of font resources (‘NFNT’, ‘sfnt’ or ‘FONT’) during installation.
n Installation of a font strike that has been split among multiple resources on multiple source disks.
Using the Font Atom
Auto-Routing Under Pre-7.1 Systems
To overcome the effort involved with installing fonts into the various versions of System Software, the Installer will automatically place the font resources into the System file if installing into a System Folder that does not support the “Fonts” folder. To use this feature, write your script to always install into a file in the System Folder’s “Fonts” folder. Make the target file path start with the reserved folder name “special-font” and reference this target file spec. from the Font Atom, and the Installer will handle the rest.
NOTE
System Software installation scriptwriters should understand how the Installer decides where the font resources will be installed to avert disasters, and bugs. The Installer uses the version of the target System file and the existence of a Resource Atom installing the ‘fld#’ resource to decide whether to auto-route or not. You must be installing a ‘fld#’ resource into a pre-7.1 System file at the same time as the fonts to let the Installer know you are upgrading to System 7.1 or newer. u
Using Atom Extenders with Font Atoms
You’ll use an Atom Extender to decompress font resources that were compressed by you to save space on your source disks. Minor constraints are required when using the Font Atom with this feature.
Scriptwriters must specify individual strikes(size and style) to copy when using an Atom Extender to decompress font resources. This is required because the target piece sizes for each strike must be entered in the optional source list. It’s recommended to place compressed font resource data into resources of type ‘part’.
The Font Atom is expanded into one or more parts that the Atom Extender receives with the kBeforePart and kAfterPart messages. As each part is installed, the Atom Extender attached to the original Font Atom will be called for each part. There will be a part for each source resource piece being copied. The only exception to this rule is for strikes that reference font resources in ROM. Since there is no data copied for these strikes the Atom Extender is not called.
NOTE
The ‘FOND’ resource is always copied using the Installer’s default copy mechanism. This prevents the scriptwriter from decompressing the ‘FOND’ resource using an Atom Extender. The ‘FOND’ resource is the road map to other font resources (‘FONT, ‘NFNT’, and ‘sfnt’), and therefore must never be compressed. We suggest that you convert the ‘FOND’ resource into the type ‘iFND’ and use the encodedFONDRsrc flag when compressing any of the font resources it references. This will prevent the system software from becoming confused when finding a ‘FOND’ resource in your source file that may reference not existent font resources. In addition, the compressed flag should NOT be set in the resource attributes of the ‘part’ resource because this flag is presently reserved for use by Apple Computer, Inc. u
Font Atom Reference
This section describes the resource description of the ‘inff’ script resource, format 1.
integer = $$CountOf (Pieces);/* Number of source pieces */ \
wide array Pieces{ \
RsrcSpec; /* Description of this piece*/ \
}
#define Strike \
integer; /* Font Size */ \
Style; /* Font Style */ \
RsrcType; /* Target Font Resource Type */ \
integer; /* Target Attributes */ \
SrcPartsList; /* Optional source pieces */
type 'inff' {
switch {
case format2:
key integer = 2; /*format version 2 */
fontFamilyAtomFlags; /* Font Atom Flags */
fileSpecID; /* Target File Spec */
fileSpecID; /* FOND Source File Spec */
integer; /* Target FOND Attributes */
unsigned longInt; /* Family Size */
rsrcID; /* Target Family Number */
switch {
case entireFamily:
key integer = 1;
case explicitFamilyMembers:
key integer = 2;
unsigned integer = $$CountOf(StrikeEntries);
wide array StrikeEntries {
Strike; /* Source for each of the strikes */
};
};
rsrcID; /* Atom Extender ID */
evenPaddedString; /* Atom Description */
evenPaddedString; /* Family Name */
};
};
Flag Descriptions
deleteWhenRemoving/dontDeleteWhenRemoving
Determines if specific font strikes or the entire family is deleted during a removal.
Using with explicitFamilyMembers copy option — When using the deleteWhenRemoving flag, if the target font strike exists and the user clicks Remove the strike is deleted. If a strike does not exist on the target disk, this flag is ignored. If all font strikes for a given family are removed, the family’s ‘FOND’ resource is also deleted.
Using with entireFamily copy option — When using the deleteWhenRemoving flag, the family’s ‘FOND’ resource and all font strikes for the family are deleted.
Note that the font atom must be part of a package that uses the removable flag.
deleteWhenInstalling/dontDeleteWhenInstalling
Determines if specific font strikes or the entire family is deleted during an installation when using the dontCopy flag.
Using with explicitFamilyMembers copy option — When using the deleteWhenRemoving flag, if the target font strike exists and the user clicks Remove the strike is deleted. If a strike does not exist on the target disk, this flag is ignored. If all font strikes for a given family are removed, the family’s ‘FOND’ resource is also deleted.
Using with entireFamily copy option — When using the deleteWhenRemoving flag, the family’s ‘FOND’ resource and all font strikes for the family are deleted.
The deleteWhenInstalling flag is primarily used for deleting previously installed font resources that are no longer needed.
copy/dontCopy Determines if the font resources are copied or not during an installation. Note that some flags (leaveAloneIfNewer, keepExisting, copyIfUpdate) can prevent copying from happening under the circumstances specified.
noEncodedFONDRsrc/encodedFONDRsrc
Allows ‘FOND’ resources to be encoded into the resource type ‘iFND’ when compessing the font resources. This is recommended to help prevent the system software from becoming confused when finding a ‘FOND’ resource in your source file that may reference not existent font resources.
tgtRequired/noTgtRequired
The target file must already exist. If the target file does not exist, the user is warned that a target file is needed. When using the noTgtRequired flag and the target file does not exist, the Installer will create one.
keepExisting/updateExisting
Allows the scriptwriter to preserve existing font resources when using the copy and/or deleteOnInstall flag. Use the keepExisting flag to prevent the Installer from disturbing an existing target font strike or family.
Using with explicitFamilyMembers copy option — When using the keepExisting flag and a specific strike in the ‘FOND’ resource already exists in the target file, it will not be replaced.
Using with entireFamily copy option — When using the keepExisting flag and the ‘FOND’ resource already exists, no strikes will be copied or replaced.
No copying will occur if the updateExisting flag is used with the copyIfUpdate flag.
copyIfUpdate/copyIfNewOrUpdate
Allows the scriptwriter to update a font resource only if it already exists. Use the copyIfUpdate flag to prevent a new resource from being created.
Using with explicitFamilyMembers copy option — When using the copyIfUpdate flag, a specific strike is copied to the target file only if the strike already exists in the target file.
Using with entireFamily copy option — The entire source font family will be copied if any strikes exist in the target file.
If the copyIfUpdate flag is used with the keepExisting flag, then no copying will occur.
ignoreProtection/dontIgnoreProtection
Determines if the user should be alerted if any font resource with its protected bit set will be replaced or deleted.
Using with explicitFamilyMembers copy option — When using the dontIgnoreProtection flag, if the ‘FOND’ resource or any font resource to be replaced has the protection flag set, the user will be alerted, and the installation will be canceled. Use the dontIgnoreProtection flag if preserving protected font resources is important. When using the ignoreProtection flag the font resources are deleted from or updated in the target file even if it any are protected in the target file.
Using with entireFamily copy option — When using the dontIgnoreProtection flag the user is alerted only if the ‘FOND’ resource is protected, but if any other font resources are protected, they will be replaced without alerting the user. When using the ignoreProtection flag the font resources are deleted from or updated in the target file even if it any are protected in the target file.
srcNeedExist/srcNeedNotExist
Determines whether the source font resources must exist on the source disk. Use the srcNeedNotExist flag if the source resources can optionally reside on the source disk. If the source file or source resources are not found, the atom it is ignored and the installation continues normally.
byID/byName Determines how the font strike resources should be found in the source files. If using the byID flag the font strike’s resources are found in the source file using only the ID. If you want to require the resource name to match as well then use the nameMustMatch flag. Note that the byID flag can only be used when installing using the explicitFamilyMembers copy option and split source resources are specified. If using the byName flag the font strike resources are found in the source file using only the name specified in the Source Piece Rsrc Name field.
nameMustMatch/nameNeedNotMatch
Specifies if the font strike resources found in the source file using their IDs must have the name in the Source Piece Rsrc Name field. Note that the nameMustMatch flag can only be used when installing using the explicitFamilyMembers copy option and split source resources are specified. This flag is ignored if the byName flag is used.
Field Descriptions
Target File Spec ID The resource ID of a Target File Spec script resource (‘intf’, or ‘infs’ for pre-4,0 scripts) describing the file on the target disk where the resource will be deleted, created, or updated. (2-bytes)
Source File Spec ID The resource ID of a Source File Spec script resource describing the file on the source disk that contains the 'FOND' resource to be copied into the target file.
Using with explicitFamilyMembers copy option — If no optional split source information is provided, the strikes specified must also be contained in the same file as the source ‘FOND’ resource. Optional split source information always overrides that default source for those strikes that use it.
Using with entireFamily copy option — The source strike resources referenced in the source 'FOND' resource must be contained in the same source file as the source 'FOND' resource.
If you’re just deleting strikes and therefore don’t need a source file, set this field to 0. (2-bytes)
Target FOND Attributes The resource attributes that will be given to the target 'FOND' resource during installation. See Inside Macintosh Vol. I, page 111 for more information about resource attributes. (2-bytes)
Font Family Size The size in bytes of all font resources including the 'FOND' resource to be installed or deleted. This field is used by the Installer in figuring the sizes for an installation. (4-bytes)
Target FOND ID The resource ID that will be given to the target 'FOND' resource. Normally, this ID should also be the same ID as the resource ID of the source 'FOND' resource. The Installer always sets the family number field contained in the ‘FOND’ resource to the resource ID of the ‘FOND’ when it is copied or updated. (2-bytes)
How-To-Copy Value Key Specifies how the font resources will be copied, or deleted. Currently, the two copy options are available: entireFamily Value (1), and explicitFamilyMembers Value (2). (2-bytes)
Using the entireFamily copy option — Tells the Installer that all strikes specified in the source 'FOND' resource will be copied. The 'FONT', 'NFNT', or 'sfnt' resources must exist in the same source file as the 'FOND' resource. The Copy Entire Family Value is provided to copy small, simple font families with minimal scripting effort. Since the target resource attributes cannot be specified, the target resource inherits the source's. If the Font Family Atom Flags are set for deleteWhenRemoving or deleteWhenInstalling & dontCopy the target 'FOND' resource and ALL of its referenced strikes will be deleted from the target file upon removal or installation. (2-bytes)
Using the explicitFamilyMembers copy option — Tells the Installer that one or more strikes are specified in the following member list. (2-bytes)
Point Size The family member's point size. (2-bytes)
Style Contains flags describing the style of the font. The style bits are defined below. (2-bytes)
Bit 0: Set for Bold
Bit 1: Set for Italic
Bit 2: Set for Underline
Bit 3: Set for Outline
Bit 4: Set for Shadow
Bit 5: Set for Condensed
Bit 6: Set for Extend
All other bits are reserved.
Resource Type The resource type of the target or source font resource. This will be the type of the font resource created by combining the split resources. If no split resource information is given, this field should be the type of the source font resource (e.g. 'FONT', 'NFNT', or 'sfnt'). (4-bytes)
Resource Attributes The resource attributes that will be given to the target font resource. The Split Resource list specifies one or more resources that make up the font resource when combined in the order listed. (2-bytes)
Split Resource File Spec ID
The Split Resource File Spec ID field is a 2-byte field that specifies the file on the source disk that contains the split resource to be combined. (2-bytes)
Split Resource Type The resource type of the source split resource. Usually, this should be type 'part'. (4-bytes)
Split Resource ID The resource ID of the source split resource. (2-bytes)
Split Resource Size The exact size in bytes of the source split resource. (4-bytes)
Split Resource Name The name of the source split resource. If the resource is being found using the byName flag, this field must be filled. To help ensure that the correct resource is being installed, the name of the resource in the source file must match this field if the resource is being found by name. (even-padded Pascal string)
Atom Extender ID The resource ID of an Atom Extender ‘inex’ script resource. This Atom Extender will be called during copying of each font resource part. (2-bytes)
Font Family Atom Description
A Pascal string describing the atom. This field is used as part of the status dialog. If this field is not empty, the status dialog displays “Reading <Description String>”, or “Writing <Description String>”. If this field is empty, the status dialog displays “Reading font: <Font Family Name>”, or “Writing font: <Font Family Name>”. (even-padded Pascal string)
Font Family Name The family name. The family name will be used to find the source and target 'FOND' resource. (even-padded Pascal string)
About the ResMerge Atom (‘inrm’)
The ResMerge Atom can be used to copy all resources from a source file to a target file. Each resource is copied separately, replacing an existing resource of the same type and ID. Because the ResMerge Atom offers no options, you may find that you will need to use individual Resource Atoms to handle special situations.
The ResMerge Atom is unique from using Resource Atoms because anyone can add to or delete resources from the source file without changing the atom. This is acceptable as long as the Installer can successfully preflight the required disk space. A field in the atom holds the total size the resources expect to occupy in the target file. This flexibility comes at a cost to ease of use because the Installer cannot determine during preflighting how many resources will be replaced, thus not requiring additional disk space. We will therefore usually overestimate the required disk space, forcing the user to make more space available than will probably be necessary.
Using the ResMerge Atom
The ResMerge Atom offers limited options, so determining when to use the ResMerge Atom versus separate Resource Atoms or a File Atom is important. The main purpose of the ResMerge Atom is to provide a simple high-level resource copy mechanism without forcing the scriptwriter to create numerous Resource Atoms.
The Installer executes a ResMerge Atom by automatically converting the atom into individual Resource Atoms when the Installer is ready to begin reading from the source disk. The Resource Atom is created with the following flags:
n dontDeleteWhenRemoving — The ResMerge Atom does nothing during a removal.
n dontDeleteWhenInstalling.
n copy.
n noTgtRequired — The target file will be created if it does not already exist.
n updateExisting — Existing resources with the same type and ID will be replaced.
n copyIfNewOrUpdate.
n srcNeedNotExist — Doesn’t really matter because if it didn’t exist we would not be creating this Resource Atom to copy it.
n byID.
n nameNeedNotMatch — The name is ignored, but the new name will replace the old name if different.
NOTE
System Software scriptwriters must use care when using the ResMerge Atom because on pre-7.0 systems we determine if the Folder Manager will be available based on the presence of a Resource Atom copying a ‘fld#’ resource. This means a separate Resource Atom must always be created to install the ‘fld#’ resource. u
ResMerge Atom Reference
The format of the ResMerge Atom is simple. Its template is shown below.
#define resMergeAtomFlags \
fill bit[16];
type 'inrm' {
switch {
case format0:
key integer = 0; /* ResMerge Atom Format version */
mergeAtomFlags; /* ResMerge Atom Flags */
unsigned longInt; /* Total Resources Size */
fileSpecID; /* Target File Spec. Rsrc ID */
fileSpecID; /* Source File Spec. Rsrc ID */
evenPaddedString; /* Status Description */
};
};
Field descriptions
ResMerge Atom Flags Currently reserved for use by Apple Computer, Inc. (2-bytes)
Total Resources Size The size that all resources will occupy in the target file. For most purposes, the size of the source file’s resource fork is an adequate estimate. This field is used by the Installer to figure the amount of disk space required. (4-bytes)
Target File Spec. Rsrc ID
The resource ID of a Target File Spec (‘intf’) script resource describing the desired location of the target file. (2-bytes)
Source File Spec. Rsrc ID
The resource ID of a Source File Spec (‘infs’) script resource describing the location of the source file. (2-bytes)
Status Description An optional string that is displayed in the Status dialog during execution of the ResMerge Atom. (even-padded Pascal string)
About the Folder Atom (‘infm’)
The Folder Atom can be used to copy all files from the root-level of a source folder to the root-level of a target folder. Each file is copied separately, replacing an existing file of the same name. Folders within the source folder are ignored, and must be copied using separate Folder Atoms. Because the Folder Atom offers no options, you may find that you will need to use individual Resource Atoms to copy some or all the resources.
The Folder Atom is unique from using File Atoms because anyone can add to or delete files from the source folder without changing the atom. This is OK as long as the Installer can successfully preflight the required disk space. A field in the atom holds the total size the source files. This flexibility comes at a cost to ease of use because the Installer cannot determine during preflighting how many files will be replaced, thus not requiring additional disk space. We will therefore usually overestimate the required disk space, forcing the user to make more space available than will probably be necessary.
NOTE
The Folder Atom only copies the files at the root level of the source folder. Nested folders must be copied separately with additional Folder Atoms. u
Using the Folder Atom
The Folder Atom offers no options, so determining when to use the Folder Atom versus separate File Atoms is important. The main purpose of the Folder Atom is to provide a simple high-level file copy mechanism without forcing the scriptwriter to create numerous File Atoms. The Folder Atom does not support decompression or version comparison.
The Installer executes a Folder Atom by automatically converting the atom into individual File Atoms when the Installer is ready to begin reading from the source folder. The File Atom is created with the following flags:
n dontDeleteWhenRemoving — The Folder Atom does nothing during a removal.
n dontDeleteWhenInstalling.
n copy.
n dontIgnoreLockedFile — The user is notified about locked target files, and the installation is stopped.
n dontSetFileLocked or setFileLocked — If the source file is locked it will be locked after it is copied.
n useSrcCrDateToCompare — Since no version compare procedure can be specified.
n srcNeedNotExist — Doesn’t really matter because if it didn’t exist we would not be creating this File Atom to copy it.
n rsrcForkInRsrcFork — Since no decompression is allowed.
n updateExisting — Existing files with the same name will be replaced.
n copyIfNewOrUpdate.
n rsrcFork — Copy resource fork if it exists.
n dataFork — Copy data fork if it exists.
Specifying the Source and Target Folder
The standard ‘infs’ and ‘intf’ file spec resources are used to specify the source and target folder with several differences:
n The path name is similar to normal file specs, but the path should end with the name of the source or target folder. A colon at the end of the path is optional.
n All File Spec flags are ignored when used with Folder Atoms.
n The File Type, File Creator and Creation Date fields are ignored when used with Folder Atoms.
NOTE
The reserved folder path name “special-xxxx” cannot be used with Folder Atoms. If you do, the user will be told the script document is damaged. u
Installing Folders with Custom Icons
The Folder Atom will automatically set the target folder to use the source folder’s custom icon if one exits. Although the scriptwriter need not be aware of how the custom icon is stored, the Installer uses the File Atom’s feature of setting the target folder’s icon whenever the special invisible “Icon\n” file is written to disk.
Creating Empty Folders with a Folder Atom
The Installer will not create a target folder if there are no files are present in the source file. If you wish to create an empty folder, the easiest work around is to create a custom icon for the source folder, thereby causing the invisible “Icon\n” file to be copied, and the target folder to be created.
Folder Atom Reference
The format of the Folder Atom is simple. Its template is shown below.
#define folderAtomFlags \
fill bit[16];
type 'infm' {
switch {
case format0:
key integer = 0; /* Folder Atom Format version */
folderAtomFlags; /* Folder Atom Flags */
unsigned longInt; /* Total Folder Size */
rsrcID; /* Target File Spec. Rsrc ID */
rsrcID; /* Source File Spec. Rsrc ID */
evenPaddedString; /* Status Description */
};
};
Field Descriptions
Folder Atom Flags Currently reserved for use by Apple Computer, Inc. (2-bytes)
Total Folder Size The size of all files in the source folder. This field is used by the Installer to figure the amount of disk space required. (4-bytes)
Target File Spec. Rsrc ID
The resource ID of a Target File Spec (‘intf’) script resource describing the desired location of the target folder. (2-bytes)
Source File Spec. Rsrc ID
The resource ID of a Source File Spec (‘infs’) script resource describing the location of the source folder. (2-bytes)
Status Description An optional string that is displayed in the Status dialog during execution of the Folder Atom. (even-padded Pascal string)
Using Action Atoms (‘inaa’)
Action Atoms are used to run a code resource at the beginning and/or end of an installation or removal.
To use an Action Atom, an 'inaa' resource must first be added to the script. This atom specifies the resource which contains an executable piece of code. The user-defined Action Atom code can be executed at two different times for installations. One is after the user clicks on the Install button but before installation begins. The other is after the installation is finished, but before the user is asked to quit or continue. The code can also be executed at two different times for removals. One is after the user clicks on the Remove button but before removal begins. The other is after the removal is finished, but before the user is asked to quit or continue. A new option allows the Busy Cursor animation to be continued/suspended during execution of the action atom code resource. This option is useful when the code resource displays a dialog and the Busy Cursor is not appropriate. For installation and removal the order of execution is defined by the ID of the 'inaa' resources.
Action Atom Reference
This section describes the Action Atom resource format, data structures and function interface.
Resource Description
The format of the Action Atom is shown below.
#define actionAtomFlagsFormat2 \ fill bit[12]; \
boolean continueBusyCursors, suspendBusyCursors \
boolean actAfter, actBefore; \
boolean dontActOnRemove, actOnRemove; \
boolean dontActOnInstall, actOnInstall;
type 'inaa' {
switch {
case format2:
key integer = 2; /* Action Atom Format version. */
actionAtomFlagsFormat2; /* Action Atom Flags */
literal longint; /* Code Resource Type */
integer; /* Code Resource ID */
longint; /* RefCon */
longint; /* Requested Memory (in bytes) */
evenPaddedString; /* Status Description */
};
};
Flag Descriptions
continueBusyCursors/suspendBusyCursors
Controls whether the counting fingers busy cursor should be stopped and an arrow cursor shown prior to calling the Action Atom code resource. Use the suspendBusyCursors flag when you want to display a dialog from within your Action Atom code resource.
actAfter/ActBefore Determines whether this Action Atom code resource is called before or after the installation/removal.
dontActOnRemove/actOnRemove
Determines if this Action Atom code resource should be called on a removal.
dontActOnInstall/actOnInstall
Determines if this Action Atom code resource should be called on an installation.
Field descriptions
Code Resource Type The resource type of the code resource, usually ‘infn’. (4-bytes)
Code Resource ID The resource ID of the code resource. (2-bytes)
RefCon A value to be passed directly to the code resource. For example, the System 7.X Installer script has all of its Action Atoms linked together into one code resource and uses this refCon value as a selector that tells which action atom to run. By linking all action atoms together into one code resource and eliminating duplicate code, we cut the size of our action atoms in half. (4-bytes)
Requested Memory The requested number of bytes that should be available in the Action Atom’s sub-heap when called. Enter 0 (zero) to not create a sub-heap and run inside the Installer’s heap. Please see warnings about using sub-heaps in the Atom Extender section if you specify a value other than 0. (4-bytes)
Status Description An optional string that is displayed in the Status dialog during execution of the Action Atom. (even-padded Pascal string)
Data Structures
Function Interface
The entry point of the Action Atom code resource must have the interface:
The Action Atom should return a result telling the Installer what to do after executing the code resource. You can use these constants to specify the result code:
enum { kActionAtomResultFatalError = -1,
kActionAtomResultContinue = 0,
kActionAtomResultCancel = 1 };
typedef long ActionAtomResult;
Return results produce the following effect:
n Return kActionAtomResultContinue if you wish the installation to continue.
n Return kActionAtomResultCancel to cancel the installation, just as if the user had pressed the Cancel button. When an action atom returns the cancel message, all action atom waiting in the queue are not run. Cancel messages are then sent to all ‘after’ action atoms to allow them to clean up their environment.
n Return kActionAtomResultFatalError to signal that there is something seriously wrong, and the installation should not continue. When an action atom returns the error message, all action atoms waiting in the queue are not run. Cancel messages are then sent to all ‘after’ action atoms to allow them to clean up their environment.
s W A R N I N G
If you choose to create a sub-heap for each invocation of format 2 of the Action Atom please read the section “Running with a Sub-Heap” within the Atom Extender portion of this document. You can enter 0 (zero) in the requested memory field to not create a sub-heap and run inside the Installer’s heap. s
Parameter Block
The Action Atom parameter block contains information about the Installer’s environment. The parameter block has the structure:
typedef struct {
InstallationStage fMessageID;
Handle fStaticDataHdl;
ProcPtr fCallBackProcPtr;
short fTargetVRefNum;
long fTargetFolderDirID;
short fSystemVRefNum;
long fSystemBlessedDirID;
long fRefCon;
Boolean fDoingInstall;
Boolean fDidLiveUpdate;
long fInstallerTempDirID;
}ActionAtom2PBRec, *ActionAtom2PBPtr;
Field Descriptions
fMessageID One of three messages the Atom Extender will receive when being called. Use these constants to understand the message ID:
enum {before,
after,
cleanUpCancel };
typedef unsigned char InstallationStage;
If your Action Atom is running before the installation takes place, the fMessageID field is before.
If your Action Atom is running after the installation completes successfully, the fMessageID field will be after.
If the user clicks the Cancel/Stop button, or the Installer cancels the installation because of an error, cleanUpCancel messages are sent to all ‘after’ action atoms to allow them to clean up their environment. Each ‘after’ action atom is guaranteed to receive only one cancel message if the installation is canceled or stopped. This may happen before the ‘before’ actions atoms have run, so it’s important to be smart within your cleanup routines.
fStaticDataHdl A handle created by the Action Atom using INewHandle to save information between before and after calls to this Action Atom. The field is always NULL when receiving a before message. You can assign a value to this field during the first call to the Action Atom, and receive the same value in this field during the next call.
fCallBackProcPtr A pointer to the Installer’s dispatch routine. You’ll need to pass this field as a parameter to glue routines that provide access to Installer functions.
fTargetVRefNum The target disk’s vRefNum. When allowing the user to select a target application folder, this is the volume on which the folder resides.
fTargetFolderDirID The target application folder’s directory ID. Target File Specs that use the reserved folder path folder-user will be placed in this folder. This value is -1 if the Installer is using disk mode, the folder does not exist, or a File Spec referencing the reserved folder path folder-user has not been referenced by any atom included in the installation.
fSystemVRefNum The system disk’s vRefNum. Target File Specs that use the reserved folder path special-xxx will be placed in the System Folder on this volume.
fSystemFolderDirID The directory ID of the System Folder on the disk with the refNum fSystemVRefNum. This directory is not necessarily the currently active System Folder.
fRefCon A 4-byte value defined by the scriptwriter in the ‘inex’ script resource.
fDoingInstall TRUE if the user is performing an installation; otherwise, FALSE if the user is removing.
fDidLiveUpdate TRUE if the Installer is modifying files inside the active System Folder.
fInstallerTempDirID The directory ID of the temporary folder on the volume specified in the fSystemVRefNum field. The temporary folder holds the files that we are modifying to allow rollback in case the installation is canceled. You’ll rarely ever need to look inside this folder.
Using Audit Atoms (‘inat’)
During the development of System Software scripts, there were many times we wished that there was a history of what had previously been installed. For example, the user did a minimal SE System Software installation, and later wanted to add minimal Macintosh II System Software. During the second installation, the Installer should be smart enough to update the disk with both SE and II software. Installer Audit Atoms were added to facilitate this type of updating. Their format is shown below.
When the Installer finds an Audit Atom in a script, after an installation is complete, it adds a new resource (type 'audt') to the target file specified in the Audit Atom. This resource contains an array of audit selector/value pairs. If an 'audt' resource already exists in the target file and there is no entry for the given selector, an entry is added. If an entry for the selector already exists, the higher of the two values is used. Using the Installer Rules checkAuditRecord and checkAnyAuditRecord, later installations can make decisions based on this history.
Audit Atom Reference
Resource Description
Format 0 of the ‘inat’ resource:
type 'inat' {
switch {
case format0:
key integer = 0;
FileSpecID; /* Target File Spec Rsrc ID*/
OSType; /* Audit Selector */
literal longint; /* Audit Value */
};
};
Field descriptions
Target File Spec. Rsrc ID
The resource ID of a Target File Spec. of which you want to add or update the audit resource. Apple uses the System File to keep a history of System Software that has been installed. A File Spec ('intf' resource) must exist in the script with this ID. (2-bytes)
Audit Selector A meaningful type. (4-bytes)
Audit Value A meaningful value. (4-bytes)
Using Boot Block Atoms (‘inbb’)
Boot Block Atoms are used to write or change the parameters in a target volume’s boot blocks. Boot Block Atoms are different from file and resource atoms – they can indicate something to be copied, or indicate an individual parameter that needs to be changed.
To cause boot blocks to be written to a target volume, include a Boot Block Atom with a key of type 'bbUpdate'. The argument to this type of Boot Block Atom is an integer which indicates the ID of a File Spec in the script. The file indicated by this File Spec should contain a 'boot' resource. A copy of the resource is written to the first two blocks of the target volume.
Boot Block Atom Reference
Resource Description
Format 0 of the ‘inbb’ resource:
#define BootBlockAtomFlags \
fill bit[14]; \
boolean dontChangeOnInstall, changeOnInstall; \
boolean dontChangeOnRemove, changeOnRemove;
#define BootBlockUpdateFlags \
fill bit[7]; \
boolean replaceBBSysName, saveBBSysName; \
boolean replaceBBShellName, saveBBShellName \
boolean replaceBBDbg1Name, saveBBDbg1Name; \
boolean replaceBBDbg2Name, saveBBDbg2Name; \
boolean replaceBBScreenName, saveBBScreenName; \
boolean replaceBBHelloName, saveBBHelloName; \
boolean replaceBBScrapName, saveBBScrapName; \
boolean replaceBBCntFCBs, maxBBCntFCBs; \
boolean replacebbCntEvts, maxBBCntEvts \
type 'inbb' {
switch {
case format0:
key integer = 0;
BootBlockAtomFlags;
switch {
case bbUpdate:
key integer = -1;
RsrcID;
BootBlockUpdateFlags;
case bbID:
key integer = 1;
decimal integer;
case bbEntry:
key integer = 2;
decimal longint;
case bbVersion:
key integer = 3;
decimal integer;
case bbPageFlags:
key integer = 4;
decimal integer;
case bbSysName:
key integer = 5;
EvenPaddedString;
case bbShellName:
key integer = 6;
EvenPaddedString;
case bbDbg1Name:
key integer = 7;
EvenPaddedString;
case bbDbg2Name:
key integer = 8;
EvenPaddedString;
case bbScreenName:
key integer = 9;
EvenPaddedString;
case bbHelloName:
key integer = 10;
EvenPaddedString;
case bbScrapName:
key integer = 11;
EvenPaddedString;
case bbCntFCBs:
key integer = 12;
decimal integer;
case bbCntEvts:
key integer = 13;
decimal integer;
case bb128KSHeap:
key integer = 14;
decimal longint;
case bb256KSHeap:
key integer = 15;
decimal longint;
case bb512KSHeap:
key integer = 16;
decimal longint;
case bbSysHeapSize:
key integer = 16;
decimal longint;
case bbSysHeapExtra:
key integer = 18;
decimal longint;
case bbSysHeapFract:
key integer = 19;
decimal longint;
};
EvenPaddedString; /* Boot Block Atom Description */
};
};
Flags descriptions
dontChangeOnInstall/changeOnInstall
Determine if the boot blocks should be updated during an installation. (2-bytes)
dontChangeOnRemove/changeOnRemove
Not currently supported. (2-bytes)
Field descriptions
Boot Block Value Key Specifies which boot block parameter is being given a value in the Boot Block Value field. The key can correspond to any of the parameters which are changeable in the boot blocks. (2-bytes)
The possible keys for this field are as follows:
bbUpdate Copy over boot blocks from a 'boot' resource found in the file whose File Spec ID is given in the 2-byte value field. A second 2-byte value field is used for this type of Boot Block Value. This second value field is used to specify which boot block fields are to be updated from the 'boot' resource, and which ones are to be preserved on the target disk. If bits 0 through 6 are set, the appropriate value on the target is kept if it appears to be a legal value or string. If bits 7 or 8 are set, the maximum parameter from the resource or what already exists on the target is preserved. The format of this field is as follows:
bbID The Boot Block Value field updates the boot blocks ID (2-bytes).
bbEntry The value updates the boot block entry point (4-bytes).
bbVersion The value updates the boot block version (2-bytes).
bbPageFlags The value updates the page 2 usage flags (2-bytes).
bbSysName The value updates the name of the system resource file (string).
bbShellName The value updates the name of the system shell (string).
bbDbg1Name The value updates the first loaded debugger’s name (string).
bbDbg2Name The value updates the second loaded debugger’s name (string).
bbScreenName The value updates the file name of the startup screen (string).
bbHelloName The value updates the file name of the startup program (string).
bbScrapName The value updates the file name of the system scrap file (string).
bbCntFCBs The value updates the number of FCBs to open (2-bytes).
bbCntEvts The value updates the size of the event queue (2-bytes).
bb128KSHeap This boot block field is no longer used.
bb256KSHeap This boot block field is no longer used.
bb512KSHeap The value updates the size of the system heap on a 512K Mac (4-bytes).
bbSysHeapSize The value updates the absolute size of the system heap (4-bytes).
bbSysHeapExtra This boot block field is no longer used.
bbSysHeapFract The value updates the minimal additional system heap space required (4-bytes).
Note: Under System 7.0 and greater, the system heap space and the number of FCBs to open are dynamically determined and not controlled by the boot block value.
Boot Block Value The value for the boot block parameter that was specified in the boot block value key. It has a size as given above (in parentheses). (size depends on the type of update)
About Atom Extenders (‘inex’)
Scriptwriters can use Atom Extenders to enhance or replace the default copy mechanism of the Installer. The most obvious purpose of the Atom Extender is to provide transparent decompression of files during installation. Scriptwriters presently using Action Atoms to perform decompression, either written by themselves or a third-party developer, will want to use Atom Extenders for this purpose in the future.
If you want to write an Atom Extender then read the section “Writing Atom Extenders” to learn how. If you only want to take advantage of an Atom Extender someone else has written then consult the sections describing the File Atom, Resource Atom and Font Atom.
Writing Atom Extenders
An Atom Extender is a newly-defined script resource of type ‘inex’ that can be referenced from new versions of the File Atom, Resource Atom, and Font Atoms. At the heart of the Atom Extender is a code resource (provided by the scriptwriter) that contains the necessary 68K code to be executed at the desired point in the installation.
This section describes the necessary steps to create an Atom Extender.
Creating an ‘inex’ Script Resource
The new ‘inex’ script resource contains the necessary information to properly call the specified code resource.
continueBusyCursors, /* Show busy cursor during call */
'infn', /* Resource type of code resource */
128, /* Resource ID of code resource */
100, /* RefCon (long integer) */
30720, /* 30K of requested free memory in heap */
"This is a test." /* Status description during call */
}
};
The sample ‘inex’ resource in Code Listing 3-1 asks the Installer to call the code resource with the type ‘infn’ and ID = 128 before the Installer begins copying the atom’s data from which the Atom Extender is referenced. When the code resource is called it will have a maximum of 30720 bytes of free memory in its own heap, from which it can allocate memory using Memory Manager routines, such as NewPtr and NewHandle. You must check the actual size of the heap at the beginning of your code resource to make sure you were allocated the full amount, since the Installer calls you whether or not your requested was fully granted. This error will usually be an idication that the Installer’s memory partition is set too low. The actual heap size is usually 5K larger than the requested size, but you should never depend on this being true.
NOTE
Atom Extenders are only called during installations, never during removals. u
Writing a Simple Atom Extender
A very simple task for an Atom Extender is to simulate the default copy task of the Installer using the supplied Installer routines. In Code Listing 3-2 the function reads and writes the atom’s data using the Installer routines ReadSourceData and WriteTargetData.
Code Listing 3-2 Simple Atom Extender performing a direct copy of an atom’s data.
// -- Read as much as we can up to the size of the buffer.
theErr = ReadSourceData( &dataLen, theBufferPtr);
// -- Loop while there is more data to read.
while( dataLen > 0 ) {
// -- This is where we can massage the data before writing it out.
// For example, if the source files were compressed, this is
// where we might call our decompression routine.
// -- Write the data out.
theErr = WriteTargetData( dataLen, theBufferPtr);
// -- Read as much as we can up to the size of the buffer.
if( theErr == noErr ) {
theErr = ReadSourceData( &dataLen, theBufferPtr);
// -- If we got eofErr, then we know we're done,
// and dataLen will be 0 (zero).
if( theErr == eofErr )
theErr = noErr;
}
} // while not done copying
if( theErr == noErr )
resultCode = kCopiedData;
else
resultCode = kFatalError;
// -- Dispose the buffer
DisposPtr(theBufferPtr);
}
else
resultCode = kFatalError;
break;
// -- For this example, we ignore the other messages.
case kInitialize:
case kAfterPart:
case kSuccess:
case kCancel:
resultCode = kContinueAsNormal;
break;
}
return resultCode;
}
Once the code in Code Listing 3-2 has been compiled into a code resource, it can be called from any atom and will copy the atom’s data as if the Installer had performed the copy. This also works for atoms whose source pieces have been split across multiple source disks, because the Installer keeps track of where each source piece should be written in the target file. The Installer data routines are similar to high-level File Manager routines:
n ReadSourceData — Similar to FSRead.
n WriteTargetData — Similar to FSWrite.
n SetTargetDataPos and SetSourceDataPos — Similar to SetFPos.
n GetTargetDataPos and GetSourceDataPos — Similar to GetFPos.
n GetTargetDataEOF and GetSourceDataEOF — Similar to GetEOF.
One of five messages can be sent to the Atom Extender. Flags in the ‘inex’ resource specify which messages the Atom Extender wishes to receive. The Atom Extender writer can examine the fMessageID field in the parameter block to determine which message has been sent. The following messages have been defined:
n kInitialize — Sent after the user clicks the Install button and preflighting has successfully completed.
n kBeforePart — Sent after the Installer has opened the atom’s source file and is about to copy the atom’s data.
n kAfterPart — Sent after the atom’s data has been successfully copied.
n kSuccess — Sent after the entire installation has successfully completed.
n kCancel — Sent after an installation was stopped due to an error or cancelation by the user, Action Atom or Atom Extender.
The Atom Extender must return a result telling the Installer what to do after receiving each message. The result codes, kFatalError, kContinueAsNormal, kCancelInstallation can be returned for any message. If you do not want to change the default action of the Installer, return kContinueAsNormal; otherwise, return kFatalError or kCancelInstallation to stop the installation. If the message was kBeforePart and you’ve copied the data yourself (with or without the supplied Installer routines) then return kCopiedData.
Memory Allocation within Atom Extenders
When the Atom Extender is executed, memory allocated using Macintosh OS/Toolbox routines will come from a sub-heap created by the Installer. The size of the sub-heap is determined by the requested free memory field of the ‘inex’ resource, and the available room in the Installer’s heap. You must check the actual size of the heap to make sure you were allocated all of the memory you requested, since the Installer calls you whether or not all your request was allocated. This helps the Installer maintain better control over all memory allocation.
The scriptwriter may need to adjust the size of the Installer’s partition to make sure enough memory is always available for the Atom Extender’s needs. The following equation helps determine the Installer’s partition size for the required free memory and other factors.
runTimeSize = size of the largest: ‘FOND’ resource, Desk Accessory resource, or owned resource being copied.
extenderSize = largest required free memory of any Atom Extender + code size of all Atom Extenders, in use during an installation + the total amount of static memory allocated.
Installer 4.0 provides memory management routines of its own to allow Atom Extenders to use available memory from the MultiFinder and Installer heaps. These routines are very similar to the Memory Manager calls, but are needed to maintain compatibility with pre-7.0 MultiFinder temporary memory calls.
n INewHandle — Similar to NewHandle, but always use IDisposHandle to dispose this handle, and IHLock and IHUnlock to lock and unlock this handle. The handle may or may not have been allocated in the MultiFinder heap.
n IDisposHandle — Similar to DisposHandle.
n IHLock — Similar to HLock.
n IHUnlock — Similar to HUnlock.
The INewHandle routine has been provided for two main purposes. The first purpose is to allow access to extra memory, when available, to make the actions of an Atom Extender more efficient. The second purpose is to allow memory to be maintained over invocations of an Atom Extender.
Running within a Sub-Heap
A sub-heap for memory allocation is mandatory for Atom Extenders to prevent gridlock when buffering data. Sub-heaps are optional for the other code resources that can be called during an installation, such as search procedures, Action Atoms and rule functions. We suggest some do’s and don’ts on dealing with sub-heaps below.
DO’s:
n Sub-heaps are mandatory for Atom Extenders, but other code resources can run inside the Installer’s heap, so enter 0 (size) as the request memory size if you don’t want to bother with sub-heaps.
n Set the current zone to the application heap before calling any Toolbox routine, and restore it afterwards. This assures that memory allocated within these calls won’t get left in your sub-heap.
n Use the Installer’s memory routines, unless you want the memory allocated directly from your sub-heap.
DON’Ts:
n Watch out for memory that is left in the sub-heap after you return control to the Installer that the system may have references to. If you set the current zone to the application heap before calling any Toolbox routine you shouldn’t have any problems. For example, if you call the GetResource routine (without properly setting the zone) that allocates a handle inside your sub-heap the Installer may crash after returning control to the Installer
n Never return a reference to a handle allocated in your sub-heap for the fStaticDataHdl field. Since the sub-heap is destroyed between invocations of the code resource, it’s best to use INewHandle to allocate any handle you store in the fStaticDataHdl field.
n Never assume you received a sub-heap of the full size requested. Check that you have enough memory enough to complete your task, since the Installer calls you whether or not your full request was allocated. Look for warning messages in the Installer Debugger to help identify this situation.
Converting Existing Decompression Code
Conversion is simple for those decompressors that access files using standard File Manager calls. The Installer routines have been designed to easily replace calls to the high-level File Manager routines: FSRead, FSWrite, SetFPos, GetFPos and GetEOF.
If your decompression code must use a temporary file to store partially decompressed data, then it’s up to you to create and destroy this file. Space on the target disk can be reserved by adding the needed space to one File Atom installed to the target disk. As an alternative, the Installer INewHandle routine can be used to allocate a temporary buffer if sufficient memory exists, but the availability of this memory is never guaranteed.
If your original decompression code comes from an application and you are using the MPW development system, make sure to read Tech. Note #256. To access global data you will need to create your own A5 world and switch back to the Installer’s A5 world before calling any Installer routine or Mac Toolbox trap. Avoiding global data makes writing code resources easier unless your development system (i.e. THINK C) supports using the A4 register to access global data.
Atom Extender Reference
This section describes the data structures and routines that are used by Atom Extenders. You’ll need to include the interface file “AtomExtenderHeader.h” or “AtomExtenderHeader.p” to have access to these data structures and routines.
Resource Description
Information about how to call the Atom Extender code resource is contained in the script resource of type ‘inex’. New versions of File Atoms, Resource Atoms and Font Atoms reference the ‘inex’ resource using its resource ID. The resource has the template:
sendInitMessage Asks to send an kInitialize message to those Atom Extenders attached to atoms that will be executed during the installation. The Atom Extender receives the kInitialize message after each time the user clicks the Install button and preflighting is successful. The purpose of the kInitialize message is to allocate any static memory needed to communicate between Atom Extenders.
sendBeforeMessage Asks to send a kBeforePart message to the Atom Extender code resource when the atom part is ready to be copied. The Installer has found and opened the source file that the part exists in and is ready to begin buffering the source data. The Atom Extender can override the Installer’s default copy mechanism by using the supplied routines and returning a kCopiedData result code.
sendAfterMessage Asks to send an kAfterPart message to the Atom Extender code resource for each part that has been successfully written by the Installer or Atom Extender. An kAfterPart message is only sent if the Installer performed the copy or the Atom Extender called WriteTargetData (with data length greater than 0) during a kBeforePart message.
sendSuccessMessage Asks to send a kSuccess message to the Atom Extender code resource after the entire installation has successfully completed. The purpose of the kSuccess message is to allow disposal of any static memory allocated during the kInitialize message, and delete any temporary files that were created by the Extender. Only those Atom Extenders that received kInitialize messages will be sent a kSuccess message.
sendCancelMessage Asks to send a kCancel message to the Atom Extender code resource when the user cancels the installation, an error forces the installation to stop, or an Atom Extender cancels the installation. The purpose of the kCancel message is to reverse any changes that were made during the installation, and dispose of any static memory allocated during the kInitialize message. Only those Atom Extenders that received kInitialize messages will be sent a kCancel message.
Field descriptions
Code Resource Type The resource type of the Atom Extender code resource to be called. (4-bytes)
Code Resource ID The resource ID of the Atom Extender code resource to be called. (2-bytes)
RefCon Value The value that will be passed in the fRefCon field of the Atom Extender parameter block. (4-bytes)
Required Free Memory The minimum number of free bytes the Atom Extender needs in its own heap to make local allocation of memory using Macintosh OS/Toolbox routines. (4-bytes)
Status Description An optional string that is displayed in the Status dialog during execution of the Atom Extender. (even-padded Pascal string)
Data Structures
Function Interface
The entry point of the Atom Extender code resource must have the interface:
The Atom Extender should return a result telling the Installer what to do after executing the code resource. You can use these constants to specify the result code:
typedef enum {
kFatalError = -1, /* Stop installation with error user dialog. */
kContinueAsNormal = 0, /* Request default action from Installer. */
kCancelInstallation = 1, /* Cancel installation with cancel user dialog. */
The AtomExtender parameter block contains information about the atom being installed. Most Atom Extenders will only need to reference a few fields from this parameter block. The parameter block has the structure:
typedef struct {
ExtenderMessageID fMessageID;
Handle fStaticDataHdl;
ProcPtr fCallBackProcPtr;
short fTargetVRefNum;
long fTargetFolderDirID;
short fSystemVRefNum;
long fSystemBlessedDirID;
long fRefCon;
DataType fDataType;
} EnvironsHeaderRec;
typedef struct {
FSSpec fSourceFile;
FSSpec fTargetFile;
long fTotalTargetSize;
long fTargetPosStart;
long fTargetPartSize;
long fSourcePartSize;
long fInstallerTempDirID;
} CopyHeaderRec;
typedef struct {
EnvironsHeaderRec fEnvironmentHeader;
CopyHeaderRec fCopyPBHeader;
} BasicCopyRec;
typedef struct {
EnvironsHeaderRec fEnvironmentHeader;
CopyHeaderRec fCopyPBHeader;
ResType fSourceRsrcType;
short fSourceRsrcID;
ResType fTargetRsrcType;
short fTargetRsrcID;
Str255 fTargetRsrcName;
short fTargetRsrcAttrs;
} RsrcCopyRec;
typedef struct {
EnvironsHeaderRec fEnvironmentHeader;
TCopyHeaderRec fCopyPBHeader;
ResType fSourceFontRsrcType; /* usually ‘part’ */
short fSourceFontRsrcID;
ResType fTargetFontRsrcType; /* FONT, NFNT, or sfnt */
short fTargetFontRsrcID;
Str255 fTargetFontRsrcName;
short fTargetFontRsrcAttrs;
Str255 fFamilyName;
short fFamilyID;
short fFontSize;
short fFontStyle;
} FontCopyRec;
typedef union {
BasicCopyRec fBasicPBRec;
BasicCopyRec fFileCopyPBRec;
RsrcCopyRec fRsrcCopyPBRec;
FontCopyRec fFontCopyPBRec;
} ExtenderPBRec, *ExtenderPBPtr;
Field descriptions
fMessageID One of five messages the Atom Extender will receive when being called. Use these constants to understand the message ID:
typedef enum {
kInitialize = 0,
kBeforePart = 1,
kAfterPart = 2,
kSuccess = 3,
kCancel = 4
} ExtenderMessageID;
Certain fields in the Atom Extender parameter block may or may not be valid when receiving a specific message. Each of the following field descriptions include a note about when the field is valid.
fStaticDataHdl A handle created by the Atom Extender using INewHandle to save information between calls to this Atom Extender code resource. The field is always NULL when receiving an kInitialize message. You can assign a value to this field during any call to the Atom Extender, and receive the same value in this field during the next message. (Valid for all messages.)
fCallBackProcPtr A pointer to the Installer’s dispatcher routine. You’ll need to pass this field as a parameter to glue routines that provide access to Installer functions. (Valid for all messages.)
fTargetVRefNum The target disk’s vRefNum. When allowing the user to select a target application folder, this is the volume on which the folder resides. (Valid for all messages.)
fTargetFolderDirID The target application folder’s directory ID. This value is -1 if the user cannot select a target application folder. Target File Specs that use the reserved folder path folder-user will be placed in this folder. (Valid for all messages.)
fSystemVRefNum The System disk’s vRefNum. Target File Specs that use the reserved folder path special-xxx will be placed in the System Folder on this volume. (Valid for all messages.)
fSystemFolderDirID The directory ID of the System Folder on the disk with the refNum fSystemVRefNum. This directory is not necessarily the currently active System Folder. (Valid for all messages.)
fRefCon A 4-byte value defined by the scriptwriter in the ‘inex’ script resource. (Valid for all messages.)
fDataType One of five values that specifies the type of data the Atom Extender has been given. Use this value to determine which type of atom is being installed, and which variant of the parameter block should be used. Use these constants to understand the data type:
typedef enum {
kFileAtomDataFork = 0,
kFileAtomRsrcFork = 1,
kFileAtomRsrcForkInDataFork = 2,
kRsrcAtom = 3,
kFontAtom = 4
} DataType;
(Valid for all messages.)
fSourceFile An FSSpec record specifying the source file from which the source data is read. (Valid only for kBeforePart and kAfterPart messages.)
fTargetFile An FSSpec record specifying the target file to which the target data is written. (Valid only for kBeforePart and kAfterPart messages.)
fTotalTargetSize The number of bytes all source pieces will occupy in the target. (Valid only for kBeforePart and kAfterPart messages.)
fTargetPosStart The offset in bytes into the target data the part’s data is written. (Valid only for the kBeforePart and kAfterPart messages.)
fTargetPartSize The size in bytes the part’s data will occupy in the target. (Valid only for the kBeforePart and kAfterPart messages.)
fSourcePartSize The size in bytes the part’s data occupies in the source. (Valid only for the kBeforePart message.)
fInstallerTempDirID The directory ID of the Installer temp folder on the target’s volume that contains the original target file. If this field is -1, the original file was not saved or did not exist. You can get the target’s volume refNum from the fTargetFile field. (Valid only for the kBeforePart and kAfterPart messages.)
Field descriptions for Resource Atoms
fSourceRsrcType The resource type of the source resource part. (Valid only for kBeforePart and kAfterPart messages.)
fSourceRsrcID The resource ID of the source resource part. (Valid only for kBeforePart and kAfterPart messages.)
fTargetRsrcType The resource type of the target resource. (Valid only for kBeforePart and kAfterPart messages.)
fTargetRsrcID The resource ID of the target resource. (Valid only for kBeforePart and kAfterPart messages.)
fTargetRsrcName The resource name to be given to the target resource. (Valid only for kBeforePart and kAfterPart messages.)
fTargetRsrcAttrs The resource attributes to be given to the target resource. (Valid only for kBeforePart and kAfterPart messages.)
Field descriptions for Font Atoms
fSourceFontRsrcType The resource type of the source font resource part. (Valid only for kBeforePart and kAfterPart messages.)
fSourceFontRsrcID The resource ID of the source font resource part. (Valid only for kBeforePart and kAfterPart messages.)
fTargetFontRsrcType The resource type of the target font resource. (Valid only for kBeforePart and kAfterPart messages.)
fTargetFontRsrcID The resource ID of the target font resource, which is not known until the part has been written by the Installer. (Valid only for the kAfterPart messages.)
fTargetFontRsrcName The resource name to be given to the target font resource. (Valid only for kBeforePart and kAfterPart messages.)
fTargetFontRsrcAttrs The resource attributes to be given to the target font resource. (Valid only for kBeforePart and kAfterPart messages.)
fFamilyName The family name (i.e. “Times”, “Geneva”… ). The source ‘FOND’ resource can be found using this name. (Valid only for kBeforePart and kAfterPart messages.)
fFamilyID The family ID. Normally this is the resource ID of the ‘FOND’ resource. (Valid only for kBeforePart and kAfterPart messages.)
About Version Compare Functions (‘invc’)
Version Compare functions allow external code resources to be called when the target file or resource’s version must be determined in order to compare with the source version number supplied in the script.
The Installer 3.X versions allow the scriptwriter to specify how it should handle the case where the target file is newer than the source file. This usually prevents downgrading the user’s software, but the opposite case may occur where downgrading is required to maintain sync-ed versions of software. Previously, the determination of “newness” was dependent on comparing the creation dates of the target file to the value in the source ‘infs’ resource. This works most of the time, but is not a reliable way to compare files.
All files being installed should have a version resource (‘vers’ 1 and maybe a ‘vers’ 2), and the ability to “newness” of files based on version resource is a desirable feature. Installer 4.0 now provides three ways to compare files:
n Old way using creation date. Use the useSrcCrDateToCompare flag in the File Atom.
n Default version number comparison using the ‘vers’ 1 resource in the target file. Use the useVersProcToCompare flag in the File Atom. Place the source version number in the Source Version Number field and place 0 (zero) in the Version Compare Rsrc ID field of the File Atom.
n Custom determination of the target version number of a file or resource using a code resource. Use the useVersProcToCompare flag in the File Atom. Place the source version number in the Source Version Number field and place the ‘invc’ resource ID in the Version Compare Rsrc ID field of the File Atom or Resource Atom.
Using Version Compare Functions with File Atoms
During preflighting of the target disk the Installer will call the Version Compare code resource for each existing target file that references a valid ‘invc’ script resource. Upon entering the code resource the current resource file will have been set to the target file, so the code resource can easily make Resource Manager calls to read an alternative version resource. If the version information is stored in the data fork, or in another file the code resource must open and close the file themselves.
The Compare Version code resource must return the version number as the function result. If an error occurs while finding the version number, then return 0 (zero).
Allowable Installer functions when comparing the version of a file:
n Memory functions: INewHandle, IDisposHandle, ILockHandle, IUnLockHandle.
n Action Handler function: RegisterAction.
Using Version Compare Functions with Resource Atoms
During preflighting of the target disk the Installer will call the Version Compare code resource for each existing target resource that references a valid ‘invc’ script resource. Upon entering the code resource the current resource file will have been set to the file the target resource resides. The code resource should call the Installer’s ReadTargetData routine to read from the target resource. This should allow most resource version schemes using a header to easily and quickly determine the version number of the resource. Using Resource Manager calls should be avoided.
The Compare Version code resource must return the version number as the function result. If an error occurs while finding the version number, then return 0 (zero).
Allowable Installer functions when comparing the version of a resource:
n Memory functions: INewHandle, IDisposHandle, ILockHandle, IUnLockHandle.
n Target functions: ReadTargeData, GetTargeDataEOF, GetTargeDataPos, SetTargeDataPos.
n Action Handler function: RegisterAction.
Version Compare Runtime Environment
The Version Compare code resource shares memory space with the Installer. Local memory allocation using Memory Manager calls will come from the Installer’s heap. Please be nice to our heap.
Version Compare Function Reference
This section describes the function interface and resource descriptions needed to use the Version Compare script resource.
Function Interface
The Installer calls your Version Compare code resource assuming the following function interface.
long ComputeVersionNumber( ComputeVersionPBPtr );
The Version Compare function writer must return a version number. The version number consists of four bytes defined from the high byte as: major revision level, minor revision level, development stage, and prerelease revision level. See Inside Macintosh: Macintosh Toolbox Essentials, page 7-31 for more details.
Parameter Block
The version compare code resource is passed a pointer to a parameter block containing the callback pointer.
typedef struct {
ProcPtr fCallBackProcPtr;
} ComputeVersionPB, *ComputeVersionPBPtr;
Field descriptions
fCallBackProcPtr A pointer to the Installer’s dispatch routine. You’ll need to pass this field as a parameter to Installer function glue routines.
Resource Description
The template of the Version Compare script resource is shown below.
#define versionCompareFlags \
fill bit[16];
type 'invc' {
switch {
case format0:
key integer = 0; /* Format version */
versionCompareFlags; /* Version Compare */
literal longint; /* Version Compare Code Rsrc Type */
integer; /* Version Compare Code Rsrc ID */
longint; /* Minimal Requested Memory */
evenPaddedString; /* Summary */
};
};
Field descriptions
Version Compare Flags Currently reserved for use by Apple Computer, Inc. (2-bytes)
Version Compare Code Rsrc Type
The resource type of the Version Compare code resource. (4-bytes)
Version Compare Code Rsrc ID
The resource ID of the Version Compare code resource. (2-bytes)
Minimal Required Memory The minimum number of free bytes the Version Compare code resource needs during execution. (4-bytes)
NOTE
Unless your Version Compare routine has a special need for it's own memory heap, you should always assign this field a value of zero. A value of zero allows the Version Compare routine to use the Installer’s allocated memory.u
Version Compare Summary An optional string briefly describing the purpose of this Version Compare function. This string is never displayed to the user. (even-padded Pascal string)
Installer Rules
This chapter describes how to use Frameworks, Rules and Rule Clauses to make intelligent installation recommendations to the user.
Frameworks (‘infr’)
Rules are evaluated when the Installer is launched; and, when needed, while the user is interacting with the interface.
Times when rules are evaluated:
n The rules are first evaluated immediately after the user dismisses the splash screen. If no splash screen is provided, then before showing the Easy Install or Custom Install dialog.
n The user selects a different target disk, application folder or system disk while in Easy Install or Custom Install.
n The user returns to the Installer from another application when running in a MultiFinder environment.
n The currently selected target disk changes because the user clicks the Eject Disk button, or inserts a disk, or the disk goes offline because of a network failure or system activity.
Global Rule Framework
The global framework provides common rules between the custom install and the easy install frameworks. The global framework will always be executed before the easy install or custom install frameworks. It allows smaller and simpler scripts by allowing the other frameworks to refer to assertions set in the global framework. All rule clauses can be called in the global framework, but those not relevant to the interface mode are ignored. The global framework is located by looking for an ‘infr’ resource of ID 765.
Easy Install Rule Framework
The Easy Install rule framework provides control over the message area in the Easy Install screen. When the Installer finds and opens the script, the Easy framework is located by looking for an ‘infr’ resource that does not have the ID of 765 or 766. This is to provide compatibility with Installer 3.4.X scripts that can use any ID for their ‘infr’ resource. It is recommended that the Easy framework resource have the ID of 764.
Custom Install Rule Framework
The Custom Install rule framework provides control over items shown in the Custom Install list. When the Installer finds and opens the script, a Custom framework is located by looking for an ‘infr’ resource of ID 766. If one is not found, the Installer uses the Installer 3.X method of determining which packages should be shown in the Custom Install list.
When a Custom Install framework is found in the script, the scriptwriter must call the new rule clause AddCustomItem for each top-level item to be displayed in the Custom Install list. The AddCustomItem rule clause accepts a list of the package (‘inpk’) IDs. The items will be listed in the order they are added. Sub-packages with the showsOnCustom flag set will automatically be added at the appropriate levels in the hierarchical Custom Install list.
Like the Easy Install framework, the Custom Install framework executes every time the user switches to Custom Install, changes the target disk/folder selection, or brings the Installer forward.
Rules (‘inrl’)
Rules, which are organized by the rule framework, provide the intelligence for making the Easy Install interface possible. Rules can examine the installation environment, save information about the installation environment to simplify other rules, provide information to the user about what the Easy Install will do for them, report errors, and/or determine which packages will be used in the Easy Install process.
Rules are composed of one or more clauses. Each clause returns a boolean value. The first clause that returns FALSE terminates the rule. If the terminated rule is part of a pickFirst set in the rule framework then the following rule, if any, is evaluated. If all of the clauses in a rule return TRUE, the rule is said to fire. If the firing rule is part of a pickFirst set in the rule framework then no more rules in the set are evaluated.
Clauses can be combined to develop the equivalent of an if-then statement. For example, the if-then statement:
IF the chosen target is a floppy disk
THEN use the package named floppyInstall in the Easy Install
would be written as a rule as follows:
resource 'inrl' (rFloppyInstall) {
format0 {{
checkTgtVolSize {floppy, floppy}, <-- A Clause
addPackages {{pFloppyInstall}} <-- Another Clause
}};
};
The scriptwriter defines the constants rFloppyInstall and pFloppyInstall earlier in the script (for example: #define rFloppyInstall 1000). This rule has two clauses. The first clause, checkTgtVolSize returns TRUE if the currently chosen target volume is a floppy. If checkTgtVolSize returns TRUE, the second clause is evaluated. This second clause, addPackages, always returns TRUE, but also has the effect of adding the package whose ID is pFloppyInstall to the list of packages to be used in the Easy Install. So, if the first clause is TRUE, the addPackages clause will be TRUE and the rule will fire.
Clauses can be ANDed together. For example, we could write:
IF the chosen target is a floppy disk
AND we are installing on a Mac+
THEN return the package named floppyInstall to Easy Install
AND add “• Mac+ Floppy Installation” to the Easy Install text
This rule has four clauses. If the first two return TRUE (i.e., we are installing onto a floppy and the current machine is a Mac Plus) then the second two clauses will be evaluated. Note that the clauses addPackages and addUserDescription always return TRUE.
For a more complete example, suppose you wanted to add a piece of text to the Easy Install message which described the machine you were installing onto. The pseudo code is as follows:
IF (Machine=Plus) THEN
Return the message 'Installing onto your Macintosh Plus'
ELSE IF (Machine=SE) THEN
Return the message 'Installing onto your Macintosh SE
ELSE IF (Machine=II) THEN
Return the message 'Installing onto your Macintosh II'
The rule framework is as follows:
resource 'infr' (kEasyInstallFrameworkRsrcID ) {
format0 {{
pickFirst, {rPlusUD, rSEUD, rIIUD},
}}
};
The rules which this framework references are as follows:
addUserDescription {'Installing onto your Macintosh II}
}};
};
The constants, rPlusUD, rSEUD, and rIIUD would be defined in the script before being used.
Using Assertions
It is often useful to keep track of information about the type of installation that is being done. This allows a more natural script organization. Note: The Installer clears all assertions prior to firing rules. Suppose, for example, that many of the rules in a script depended on knowing whether an update or a new install was being done. The pseudocode for this is as follows:
IF System File Exists
AND Installing on Mac+
THEN Use Mac+ Update packages
IF System File Exists
AND Installing on MacSE
THEN Use MacSE Update packages
More conveniently (and with better performance):
IF System File Exists
THEN Assert(updating)
IF updating
AND Installing on Mac+
THEN Use Mac+ Update packages
IF updating
AND Installing on MacSE
THEN Use MacSE Update packages
Assertions provide this functionality. Using assertions is a three-step process: 1) define a unique constant for the assertion, 2) set the assertion using an AddAssertion clause, and 3) check the assertions via CheckAllAssertions, CheckAnyAssertion, CheckMoreThanOneAssertion, CheckAllNonAssertions, or CheckAnyNonAssertion clauses. The above example is written as follows:
gestaltSelector A selector value specifying the type of system information to check. (4-bytes)
gestaltReturnValuesList A list of Gestalt return values. If the Gestalt result matches one of the values in the list the function will return TRUE. (4-bytes)
DESCRIPTION
Use the CheckGestalt clause to check a Gestalt attribute. CheckGestalt takes two arguments: a Gestalt selector, and a list of valid Gestalt return values. The Installer calls Gestalt with the given selector. If the Gestalt return value is in the list of valid return values, checkGestalt returns TRUE.
NOTE
If the Gestalt selector specified requires a value containing flags ( or a bit mask ), you should use the CheckGestaltAttributes routine described below. u
gestaltSelector A selector value specifying the type of system information to check. (4-bytes)
bitMask A bit mask that will be AND’ed with actual result from the Gestalt call. (4-bytes)
DESCRIPTION
Use the CheckGestaltAttributes clause to check one or more specific bits in the Gestalt value. Passing a bit mask with more than one bit set will effectively OR the specified bits in the Gestalt result value. CheckGestaltAttributes takes two arguments: a Gestalt selector, and a bit mask. The Installer calls Gestalt with gestaltSelector, then AND’s the result value with bitMask. If this value is non-zero then CheckGestaltAttributes returns TRUE.
CheckMinMemory
CheckMinMemory{ minimalMemory }
minimalMemory The minimal number of megabytes of physical memory. (4-bytes)
DESCRIPTION
Use CheckMinMemory to specify the minimal amount of physical memory needed for an installation. Note that you cannot use CheckGestalt for this job unless you want to list all of the memory configurations applicable for an installation. CheckMinMemory takes a single argument: the minimal amount of memory (in MB) needed for this clause to be TRUE.
CheckFileDataForkExists
CheckFileDataForkExists{ targetFileSpecRsrcID }
targetFileSpecRsrcID A Target File Spec resource ID. (2-bytes)
DESCRIPTION
Use CheckFileDataForkExists to determine whether a specific file has a data fork. It takes a single argument: the Target File Spec ID of the file you are interested in. CheckFileDataForkExists returns TRUE if the file referenced by the File Spec exists and has a data fork.
CheckFileRsrcForkExists
CheckFileRsrcForkExists{ targetFileSpecRsrcID }
targetFileSpecRsrcID A Target File Spec resource ID. (2-bytes)
DESCRIPTION
Use CheckFileRsrcForkExists to determine whether a specific file has a resource fork. It takes a single argument: the Target File Spec ID of the file you are interested in. It returns TRUE if the file referenced by the File Spec exists and has a resource fork. CheckFileRsrcForkExists is a convenient way to see if a file which contains code exists..
targetFileSpecRsrcID A Target File Spec resource ID. (2-bytes)
resourceType A resource type. (4-bytes)
resourceID A resource ID. (2-bytes)
DESCRIPTION
Many times it is necessary to determine whether a specific file contains a specific resource. Use the checkFileContainsRsrcByID clause to determine whether a file has a resource with a known type and ID. checkFileContainsRsrcByID takes three arguments: the File Spec ID of the target file, the type of the resource, and the ID of the resource.
targetFileSpecRsrcID A Target File Spec resource ID. (2-bytes)
resourceType A resource type. (4-bytes)
resourceName A resource name. (even-padded Pascal string)
DESCRIPTION
Use checkFileContainsRsrcByName to determine whether a file has a resource with a known type and name. checkFileContainsRsrcByName takes three arguments: the File Spec ID of the target file, the type of the resource, and the name of the resource.
targetFileSpecRsrcID A Target File Spec resource ID. (2-bytes)
majorVersNum The major version number. (2-bytes)
minorVersNum The minor version number. (2-bytes)
releaseStage The release stage. Four release stage constants are defined in the InstallerTypes.r file: development, alpha, beta, final and release. (2-bytes)
releaseNum The release number. (2-bytes)
DESCRIPTION
Use CheckFileVersion to check the version of a file. CheckFileVersion takes two arguments: the filespec ID of the file in question, and the minimal version of the file needed for this clause to be TRUE. The Installer obtains this information from the file’s 'vers' ID =1 resource. If no 'vers' resource exists, CheckFileVersion returns FALSE.
For example, to check for System version 6.0.5 or newer, use the following clause.
checkFileVersion{SysFileSpec, 6, 5, release, 0};
To check for System version 7.1 or newer, use the following clause.
targetFileSpecRsrcID A Target File Spec resource ID. (2-bytes)
countryCode A country code. (2 bytes)
DESCRIPTION
Use the CheckFileCountryCode clause to determine a file’s country code (the name 'country code' has recently been changed to region code). CheckFileCountryCode takes two arguments: the File Spec ID of the file in question, and the country/region code required. The Installer obtains this information from the file’s 'vers' resource. The country (MPW 3.1) /region (MPW 3.2) codes can be found in the MPW interface file SysTypes.r.
CheckTgtVolSize
CheckTgtVolSize{ minimumSize, maximumSize }
minimumSize The minimum size of the volume in Kbytes. (4-bytes)
maximumSize The maximum size of the volume in Kbytes. (4-bytes)
DESCRIPTION
Use the CheckTgtVolSize clause to check target disk size. Note that this check is for disk size (to distinguish floppy from hard disks), not available disk space. The Installer itself handles the case where the target has insufficient space to accomplish the installation. CheckTgtVolSize takes two arguments: the smallest and largest size disks possible. To match any size disk, the minimal and maximal target disk sizes are both zero. If the minimum size is greater than zero but the maximum size equals zero, only the minimal requirement is used. Note that there are three size pairs defined in InstallerTypes.r. If you use {floppy, floppy} then checkTgtVolSize will return TRUE for 400 or 800k floppy targets. If you use {hdFloppy, hdFloppy} then checkTgtVolSize will return TRUE for high density floppy (1.4mb) targets. If you use {hardDisk, hardDisk} then checkTgtVolSize will return TRUE for any target volume of 10mb or greater.
NOTE
Since RAM disks may be most any size, make sure your rules handle this situation correctly. u
CheckRuleFunction
CheckRuleFunction{ ruleFunctionCodeRsrcID }
ruleFunctionCodeRsrcID The resource ID of a RuleFunction resource (‘inrf’). (2-bytes)
DESCRIPTION
Rule functions provide you with the ability to extend the rule-based decision-making scheme using a custom code resource written by you or someone else. When the CheckRuleFunction clause is evaluated the code resource is called and its return result determines whether the clause returns TRUE or FALSE.
To call a rule function code resource, first create a Rule Function resource (‘inrf’) that describes how to call the code resource. The Rule Function resource is described in the “InstallerTypes.r” file and the code resource can include the file “RuleFunctionHeader.h”.
When the code resource is called, the code resource receives the parameter block:
typedef struct {
ProcPtr fCallBackProcPtr;
short fTargetVRefNum;
long fTargetFolderDirID;
short fSystemVRefNum;
long fSystemBlessedDirID;
long fRefCon;
} RuleFunctionPBRec, *RuleFunctionPBPtr;
NOTE
The fTargetFolderDirID field will be -1 if the Installer is using disk mode, the folder does not exist, or a target File Spec referencing the reserved folder path folder-user has not been referenced by in another rule clause prior to calling the CheckRuleFunction rule clause. u
The code resource should use the function declaration:
long RuleFunction( RuleFunctionPBPtr );
The function must return either a TRUE or FALSE value. Constants for these values are defined as:
#define kTRUERuleFunctionResult 1
#define kFALSERuleFunctionResult 0
s W A R N I N G
If you choose to create a sub-heap for each invocation of the Rule Function please read the section “Running with a Sub-Heap” within the Atom Extender portion of this document. You can enter 0 (zero) in the requested memory field to not create a sub-heap and run inside the Installer’s heap. s
AddAssertion
AddAssertion{ { assertionValueList } }
assertionValueList A list of 2-byte assertion values that you wish to set.
DESCRIPTION
Use the AddAssertion clause to set a list of 1 or more assertions. AddAssertion takes a list of assertion constants as arguments. The constants are uniquely defined Rez symbols. addAssertion always returns TRUE.
CheckAllAssertions
CheckAllAssertions{ { assertionValueList } }
assertionValueList A list of 2-byte assertion values that you wish to check.
DESCRIPTION
Use CheckAllAssertions to check all of the constants a given list are currently asserted. CheckAllAssertions takes a list of assertion constants as arguments. checkAllAssertions returns TRUE if all of the items in the list have been asserted.
CheckAnyAssertion
CheckAnyAssertion{ { assertionValueList } }
assertionValueList A list of 2-byte assertion values that you wish to check.
DESCRIPTION
Use CheckAnyAssertion to check if one or more constants are currently asserted. CheckAnyAssertion takes a list of assertion constants as arguments. CheckAnyAssertion returns TRUE if one or more of the items in the list have been asserted.
assertionValueList A list of 2-byte assertion values that you wish to check.
DESCRIPTION
CheckMoreThanOneAssertion is used to detect whether more than one constant in a list of constants are currently asserted. CheckMoreThanOneAssertion takes a list of assertion constants as arguments, and returns TRUE if more than one of the constants has been asserted. CheckMoreThanOneAssertion could be used, for example, to determine whether more than one printer is being installed. In that case, display a generic message reporting that “printer software” is being installed.
ClearAssertions
ClearAssertions{ { assertionValueList } }
assertionValueList A list of 2-byte assertion values that you wish to clear.
DESCRIPTION
Use the ClearAssertions clause to clear a list of one or more assertions. ClearAssertions takes a list of assertion constants as arguments. The constants are uniquely defined Rez symbols. ClearAssertions always returns TRUE.
CheckAllNonAssertions
CheckAllNonAssertions{ { assertionValueList } }
assertionValueList A list of 2-byte assertion values that you wish to check.
DESCRIPTION
Use CheckAllNonAssertions to check all of the constants a given list are currently not asserted. CheckAllNonAssertions takes a list of assertion constants as arguments. CheckAllNonAssertions returns TRUE if all of the items in the list are not currently asserted.
CheckAnyNonAssertion
CheckAnyNonAssertion{ { assertionValueList } }
assertionValueList A list of 2-byte assertion values that you wish to check.
DESCRIPTION
Use CheckAnyNonAssertion to check if one or more constants are currently not asserted. CheckAnyNonAssertion takes a list of assertion constants as arguments. CheckAnyNonAssertion returns TRUE if one or more of the items in the list are currently not asserted.
AddAuditRec
AddAuditRec{ targetFileSpecRsrcID, selector, value }
targetFileSpecRsrcID A Target File Spec resource ID. (2-bytes)
selector The selector. (4-bytes)
value The value (4-bytes)
DESCRIPTION
The AddAuditRec clause is used to add a record to a target file’s audit record. AddAuditRec takes three arguments: a File Spec ID for the target file, an audit selector, and an audit value.
targetFileSpecRsrcID A Target File Spec resource ID. (2-bytes)
auditSelector The selector. (4-bytes)
auditValueList A list of 4-byte values.
DESCRIPTION
The CheckAnyAuditRec clause is used to determine whether a given selector and value have been entered into the audit record of a target file (specified by the File Spec ID). CheckAnyAuditRec takes three arguments: a File Spec ID for the target file, an audit selector, and a list of audit values. If the value found in the audit resource for the specified selector is contained in the list of values the clause returns TRUE.
ReportVolError
ReportVolError{ errorString }
errorString String to display. (Pascal String)
DESCRIPTION
ReportVolError is used to report an error because of a problem with the target disk (not a hard disk, disk size too small, no system, et cetera). The ReportVolError clause reports an error message in the Easy Install or Custom Install message area. ReportVolError always returns TRUE, so it can be called multiple times in a script. Messages are concatenated, just as with addUserDescription. Up to four lines can be displayed. ReportVolError takes a single even-padded Pascal string as an argument. To insert the name of the volume into the string, place the characters "^O" in the desired place.
If the Installer evaluates a ReportVolError clause, the Easy Install or Custom Install dialog displays a caution icon, and the Install button is dimmed. If you use this clause, the user can still switch volumes.
NOTE
Calling ReportVolError from within the global framework may not work correctly for some scripts. Depending on the rules within the easy or custom framework, the Install button may still be enabled. To solve this, call ReportVolError from within the easy or custom framework. u
ReportSysError
ReportSysError{ errorString }
errorString String to display. (Pascal String)
DESCRIPTION
ReportSysError is used to report an error because of a problem with the system the Installer is running on (usually unsupported hardware or a fatal error). The ReportSysError clause reports an error message to the Easy Install or Custom Install screen, which ever shows first. ReportSysError always returns TRUE, so it can be called multiple times in a script. Up to four lines can be displayed. Messages are concatenated, just as with AddUserDescription. ReportSysError takes a single even-padded Pascal string as an argument. If the Installer evaluates a ReportSysError clause, the Easy Install or Custom Install dialog displays a caution icon, and the Install button is dimmed. If you use this clause, the user cannot switch or eject volumes from the interface and has only one option: to quit.
Easy Install Rule Clauses
AddPackages
AddPackages{ { assertionValueList } }
packageIDList A list of 2-byte package resource (‘inpk’) IDs.
DESCRIPTION
The AddPackages clause is used to return a set of packages to the Easy Install screen. AddPackages can be called multiple times from a script, and the packages are unioned together. AddPackages takes a list of package IDs as arguments. addPackages always returns TRUE.
AddUserDescription
AddUserDescription{ messageString }
messageString String to display. (Pascal String)
DESCRIPTION
Use AddUserDescription to add to the text which is shown in the Easy Install dialog. AddUserDescription takes a single even-padded Pascal string as an argument. The text to be added is appended to whatever text has been previously added using the AddUserDescription clause. Up to four lines can be displayed. AddUserDescription always returns TRUE. Note that the Installer will not supply introductory information so you need to say something like: “Click the Install button to install\n{your product here}.” Use the "\n" characters to insert a return character into the description string.
Custom Install Rule Clauses
AddCustomItems
AddCustomItems{ { integer packageRsrcID } }
packageRsrcID A list of 2-byte resource IDs of ‘inpk’ resources to append to the top level of the Custom Install list.
DESCRIPTION
The AddCustomItems rule clause appends the specified packages to the top level of the custom install list regardless of the setting of its showsOnCustom flag. Each package is appended in the order listed. All sub-packages with the showsOnCustom flag set are appended at the appropriate sub-level.
File Specification
This chapter describes how to create the script resources that specify the source and target file.
About File Specifications
Most atoms require a source and target file to be specified in order to carry out the action defined by the atom. For example, when using a File Atom to copy a file from the source disk to the target disk, a Target File Spec resource (‘intf’) and a Source File Spec resource (‘infs’) must be referenced from the atom.
NOTE
When performing installations from some network servers, it is necessary that all source files have a file creation and modification time stamp that has an even value for the seconds. If you intend for installation to be performed from network servers you should set the creation and modification times of all your source files to a value such as 12:00:00 PM. u
Specifying Target Files (‘intf’)
The goal of the Target File Spec is to specify where to install the file on the target disk. In most cases the scriptwriter can hard code the path to the target file using the various reserved folder path names, or in special cases, search for the file using a code resource.
The path to the target file that must start with a colon or one of two reserved tokens (special-xxxx or folder-user). Because the target volume name is not known at the time a script is written, the scriptwriter supplies a partial path name that begins in the root directory of the target disk.
Installing into Special Folders
A scheme is provided to support special folders such as the System Folder, the Apple Menu Folder, and other Folder Manager folders. The short-hand notation used to specify a folder manager folder is “special-xxxx”, where the “xxxx” is one of the defined special folder types. The special folder types currently defined for System 7.0 through 7.1 are as follows:
Type Folder
'macs' Blessed System Folder
'prnt' PrintMonitor Documents Folder
'strt' Startup Folder
'amnu' Apple Menu Items Folder
'extn' Extensions Folder
'pref' Preferences Folder
'ctrl' Control Panels Folder
'font' Fonts Folder (applies to System 7.1 only)
This means that if the fully qualified path to the system file on the target disk was “MyVolume:MyFolder:MySystemFolder:System”, then a reference to the special folder “special-macs” would be expanded by the installer to be “MyVolume:MyFolder:MySystemFolder.” For example, if you wanted to install the Finder file into the blessed folder on the system disk, you would use the path name “special-macs:Finder” in the File Spec. If a folder in the path name does not exist, the Installer creates it. The Installer supports the use of special folders even when running on systems which do not have Folder Manager functionality. For more information about the Folder Manager, refer to the Finder chapter in Inside Macintosh, Volume VI.
To support installing into pre-7.0 systems, the Installer will automatically map special folders to the System Folder. For example, if your target is the Extensions Folder then the Installer will change the destination to the System Folder rather than create an Extensions Folder. This also applies to rule clauses that reference a file spec. While this simplifies script writing for many files that go into special folders, it does not simplify DA installation.
Localized systems are supported through a defined algorithm for determining the correct special folder name by searching for the proper ‘fld#’ resource. Given a special folder type, the Installer searches for the type in a ‘fld#’ resource in the following order:
n Installer script file
n Target System file
n Installer application file
n Booted System file
Generally, the scriptwriter should not include a ‘fld#’ resource in the script so installations into localized System Folders will happen correctly.
Installing into the User-Selected Application Folder
The scriptwriter can easily install or remove files and resources from the application folder selected by the user. This reserved folder name should only be used in conjunction with the application folder interface mode. For example, to install the file “Demo Application” into the application folder the path name might be “folder-user:Demo Application”.
Managing Rollbacks on Multiple Target Volumes
With the ability to install onto more than one target volume at a time, a complete rollback is not possible unless the original files on all target volumes are maintained. This is not always possible due to available disk space on the target volumes. The Installer always saves the original System Folder files on the boot volume, but makes the saving of all other original files optional based on the amount of available disk space on each target volume. If there is enough space to save all original files on all target volumes the ‘Cancel’ button shows in the Status dialog thereby allow for a complete rollback, otherwise a ‘Stop’ button is shown.
Installing onto the Installer Volume
To support installation onto the Installer volume, the Installer must prevent source files from being disturbed. After the user clicks the Install button, the Installer determines whether any target file matches the location of a source file. If there is a conflict the user is alerted. This case is much more likely to happen when the scriptwriter allows the user to select the target application folder.
Setting the Finder flags and Dates
Format 1 of the ‘intf’ resource supports supplying the Finder flags, creation date and modification date to make target file specification of archived files easier. The Installer sets the values of a newly created file to the specified values in the ‘intf’. If the ‘intf’ is referenced from a File or ResMerge Atom and the file already exists the Finder flags, creation and modification dates will be updated. The Finder Flags in a File Atom will always override the Finder Flags specified in the ‘intf’ resource.
If you use an ‘infs’ or format 0 of the ‘intf’ the Installer continues to use the Finder flags, creation and modification date of the source file. In cases where the source file is a compressed archive, format1 version of the ‘intf’ is recommended. ScriptCheck will fill in the correct flags and dates if the file does not reference an Atom Extender. If an Atom Extender is being used, make sure to supply the appropriate ScriptCheck extension. To have ScriptCheck fill in the correct values, place a zero in the Finder flags field and 1 in the Creation Date and Modification Date fields. If the date field is zero or 1, the Installer reverts to the older method of determining the correct target date, such as with format 0 of the ‘intf’.
Specifying Source Files (‘infs’)
The goal of the Source File Spec is to describe where the file resides on the original distribution source disk.
Source Disk Search Path
Because of multiple disk installation capability, the semantics of the File Name field are a bit complex. Customers may have copied the distribution disks onto a file server and want to install from there, or they may have made floppy backup copies of the system disks provided by Apple and expect to be able to install from those. They might also want to set up a server that users can install from. In either case, the path name specified in the File Name field of the Source File Spec will probably be slightly off (e.g. the backup disks may not have the same names as the originals) so we need to be somewhat flexible when searching for a specific source file. In a Source File Spec, the full path name (including volume name) must be given in the File Name field, but it may not be used by the Installer exactly as given.
While the Installer is flexible as to exact volume names, it requires that disk contents be the same as what is specified in the script. The Installer uses the scripts to make a list of the volumes that are needed for the installation, and the files that should be on each volume. All files that are supposed to be on the same volume must be on the same volume, but that volume’s name may be different from the name given in the script. In addition, we relax this condition slightly to allow for hard disk and network installations. When the Installer needs a disk specified in the script, it searches in the following order:
n Search for a folder with the disk’s name at the same HFS level as the script.
n Search for a folder with the disk’s name at the script parent’s HFS level.
n Search for a folder with the disk’s name at the same HFS level as the Installer.
n Search for a folder with the disk’s name at the Installer parent’s HFS level
n Search for an online volume with the correct name.
n If the Installer was not launched from an AppleShare server volume, ask for a floppy disk or CD-ROM.
The disk that the Installer is on is a special case in our requesting disk and disk content strategies. If possible, the Installer’s disk is always the first disk that we copy files and resources from. Also, the contents of the Installer disk are checked for correctness before anything is deleted or copied. We recommend that scriptwriters (especially for system releases) have the most important files and resources to be copied on the Installer disk, since that’s the only disk that we can guarantee the user has. Otherwise, the Installer could start the installation, which includes deleting all appropriate target files and resources, and have to ask for a disk that contains a crucial file, in which case the user cancels out of the dialog, since that disk is for some reason not available, thereby aborting the installation, leaving the user worse off than before (i.e., a system that no longer boots). This, of course, does not happen when doing a live install
File spec. IDs of 0 should only be used for source files specifications for the deletion of files; when the noCopy and deleteOnInstall flags are set in the 'infs' resource
File Spec. Reference
This section describes the data structures and script resources needed to reference source and target files from atoms.
Resource Descriptions
The section describes the resource definitions for the target file specification resource (‘intf’) and the source file specification resource (‘infs’).
Target File Spec. Resource (‘intf’)
The new Target File Spec. resource contains a reference to an ‘insp’ script resource which describes the file searching code resource, much like the Atom Extender script resource does.
#define targetFileFlags \
boolean noSearchForFile, SearchForFile; \
boolean TypeCrNeedNotMatch, TypeCrMustMatch; \
fill bit[14] /* Reserved */
type 'intf' {
switch {
case format0:
key integer = 0; /* Target File Spec. Format version */
fileSpecFlags; /* Target File Spec. Flags */
literal longint; /* Target File Type */
literal longint; /* Target File Creator */
literal integer; /* Search Proc. Rsrc ID */
evenPaddedString; /* Target File Path */
case format1:
key integer = 1; /* Target File Spec. Format version */
fileSpecFlags; /* Target File Spec. Flags */
OSType; /* Target File Type */
OSType; /* Target File Creator */
unsigned hex integer; /* Target File Finder Flags */
unsigned hex longint; /* Target File Creation Date */
unsigned hex longint; /* Target File Mod. Date */
rsrcID; /* Search Proc. Rsrc ID */
evenPaddedString; /* Target File Path */
};
};
Flag descriptions
noSearchForFile/SearchForFile
Determines if the Search Procedure code resource will be called. Use the searchForFile flag to override the specified file path and use the list of files returned from the Search Procedure code resource.
TypeCrNeedNotMatch/TypeCrMustMatch
Determines if the specified type and creator must match the file found on the target disk. If the type and creator of the found file do not match those specified, the installation stops the installation. This is also true of any found files returned by the Search Procedure.
Field descriptions
Target File Type The file’s type if the Installer must create one during a copy. If the TypeCrMustMatch flag is used and an existing file is found, its type must match the type entered in this field. (4-bytes)
Target File Creator The file’s creator if the Installer must create one during a copy. If the TypeCrMustMatch flag is used and an existing file is found, its creator must match the creator entered in this field. (4-bytes)
Target Finder Flags The Finder flags to be given to a new file. If referenced from a ResMerge Atom, the Finder Flags are given to the existing file. The Finder flags specified in a File Atom always override this field. Only available in format 1. (2-bytes)
Target Creation Date The creation date to be given to a new file. If referenced from a File Atom or ResMerge Atom, the existing file is given this creation date. Leave as 0 to use the source file’s or today’s date. Set to 1 to have ScriptCheck update using the source file’s creation date. Only available in format 1. (4-bytes)
Target Mod. Date The modification date to be given to a new file. If referenced from a File Atom or ResMerge Atom, the existing file is given this modification date. Leave as 0 to use the source file’s or today’s date. Set to 1 to have ScriptCheck update using the source file’s modification date. Only available in format 1. (4-bytes)
Search Procedure Rsrc ID
The resource ID of an ‘insp’ resource, which describes the code resource to call to perform the target file search. (2-bytes)
Target File Path The partial path to the target file that must start with a colon or one of two reserved tokens (special-xxxx or folder-user). (even-padded Pascal string)
Source File Spec Resource (‘infs’)
The ‘infs’ script resource is referenced from atoms.
#define fileSpecFlags \
boolean noSearchForFile, searchForFile; \
boolean typeCrNeedNotMatch, typeCrMustMatch; \
fill bit[14]
type 'infs' {
literal longint; /* File Type */
literal longint; /* File Creator */
unsigned hex longint; /* Creation Date*/
fileSpecFlags; /* File Spec Flags */
evenPaddedString; /* Full Path */
};
Flags descriptions
noSearchForFile/searchForFile
Ignored in Installer 4.0.
typeCrNeedNotMatch/typeCrMustMatch
Determines if the type and creator contained in the File Creator and File Type fields must exactly match the source file on the source disk. Use the typeCrMustMatch flag to force the type and creator to match, otherwise the installation stops with an error.
Field descriptions
Source File Type The source file’s type. If the TypeCrMustMatch flag is used the source file’s type must match the type entered in this field. Otherwise, the user is told the source disk is bad and the installation is canceled. (4-bytes)
Source File Creator The source file’s creator. If the TypeCrMustMatch flag is used source file’s creator must match the creator entered in this field. Otherwise, the user is told the source disk is bad and the installation is canceled. (4-bytes)
Creation Date The creation date the source file must have, otherwise the installation is stopped. Values of 0 or 1 are considered to match any creation date. (4-bytes)
Source File Path The full path to the source file. (even-padded Pascal string)
About File Searching (‘insp’)
Whenever you want to update or delete a file on the user’s disk but don’t know where the file will reside, you’ll need to search for it at installation time. For those File and Resource atoms you wish to search for the target file, attach a Search Procedure (‘insp’) script resource to the new Target File Spec. (‘intf’) script resource, then reference the ‘intf’ resource from the atom just as you would the older ‘infs’ script resource. Setting the searchForFile flag in the ‘intf’ resource will tell the Installer to call the code resource at the appropriate time. The built-in searching feature of the Installer will be removed and the searchForFile flag in the present ‘infs’ resource will be ignored.
The actual searching code will be supplied by you, the scriptwriter, in a code resource whose type and ID is specified in the ‘insp’ resource.
Using File Searching with File and Resource Atoms
The file searching code resource is given a pointer to a parameter block containing useful information about the Installer’s environment. The search routine performs a search for the desired file(s), then passes back a list of those files it has found, including a result code to tell the Installer whether to continue or stop.
The search routine’s task is to create and return a handle to an array of FoundFileRec records in the parameter block’s fFoundFiles field. The array should contain zero or more FoundFileRec records that specify each target file to act upon. The number of elements in the array is determined by the size of the handle. If the array has no elements, then the atom is ignored. If one FoundFileRec element is specified, then the atom (file, resource, or font atom ) is processed normally with the designated target file. If more than one FoundFileRec element is in the array, the atom is duplicated for each element.
The files that are returned to the Installer may or may not already exist. The Installer will verify that the volume and directory exist and are valid, and that the file name does not conflict with an existing directory name. If the file does not exist the Installer will create one, if necessary.
Using File Searching with Rule Clauses
File searching can also be used with Target File Specs that are referenced from rule clauses. If a Target File Spec returns more than one found file, the rule clause is duplicated for each valid file. The duplicated rule clauses are “anded” with the original rule clause. Therefore, in order for the original rule clause to return TRUE, every duplicated rule clause must also return TRUE.
Allowable Installer Functions During File Searching
While your file searching code resource is executing, you can call selected Installer functions.
Allowable Installer functions:
n Memory functions: INewHandle, IDisposHandle, ILockHandle, IUnLockHandle.
n Action Handler functions: RegisterAction.
File Searching Reference
This section describes the data structures and new script resources needed to support target file searching.
Data Structures
This section describes the function interface and parameter block passed to the Search Procedure code resource.
The Search Procedure must return a handle to an array of records describing the files it found. This array handle is defined as:
typedef struct {
short vRefNum;
long parID;
Str63 name;
short fReferenceID; /* Reserved for internal use. */
The file search code resource is passed a pointer to a parameter block containing useful information. Your code resource will want to return a handle to a list of found files in the fFoundFileArray field.
typedef struct {
—> ProcPtr fCallBackProcPtr;
—> short fTargetVRefNum;
—> long fTargetFolderDirID;
—> short fSystemVRefNum;
—> long fSystemBlessedDirID;
—> long fRefCon;
—> OSType fFileSpecType;
—> OSType fFileSpecCreator;
—> long fFileSpecCrDate;
—> Str255; fFileSpecPath;
<- FoundFileArrayHdl fFoundFilesArray;
} SearchProcedurePBRec, *SearchProcedurePBPtr;
Field descriptions
fCallBackProcPtr A pointer to the Installer’s dispatch routine. You’ll need to pass this field as a parameter to glue routines that provide access to Installer functions.
fTargetVRefNum The target disk’s vRefNum. When allowing the user to select a target application folder, this is the volume on which the folder resides.
fTargetFolderDirID The target application folder’s directory ID. This value is -1 if the user cannot select a target application folder. Target File Specs that use the reserved folder path folder-user will be placed in this folder.
fSystemVRefNum The system disk’s vRefNum. Target File Specs that use the reserved folder path special-xxx will be placed in the System Folder on this volume.
fSystemBlessedDirID The directory ID of the System Folder on the disk with the refNum fSystemVRefNum. This directory is not necessarily the currently active System Folder.
fRefCon A 4-byte value defined by the scriptwriter in the ‘insp’ script resource.
fFileSpecType The value from the Target File Type field of the Target File Spec.
fFileSpecCreator The value from the Target File Creator field of the Target File Spec.
fFileSpecCrDate The value from the Target File Creation Date field of the Target File Spec.
fFileSpecPath The value from the Target File Path field of the Target File Spec.
fFoundFilesArray A handle to an array of found target files that is created and filled by the code resource.
Resource Description
The ‘insp’ script resource is referenced from the new Target File Spec. It defines how to call the code resource that will perform the actual search.
type 'insp' {
switch {
case format0:
key integer = 0; /* Search Procedure Format version */
unsigned integer; /* Search Procedure Flags */
literal longint; /* Search Procedure Code Rsrc Type */
literal integer; /* Search Procedure Code Rsrc ID */
literal longint; /* RefCon Value */
literal longint; /* Required Free Memory */
evenPaddedString; /* Search Procedure Summary */
};
};
Field descriptions
Search Procedure Flags Currently reserved for use by Apple Computer, Inc. (2-bytes)
Search Procedure Code Rsrc Type
The type of the code resource that will be called to perform the search. (4-bytes)
Search Procedure Code Rsrc ID
The ID of the code resource that will be called to perform the search. (2-bytes)
RefCon Value The value that will be passed to the code resource in the fRefCon field of the Search Procedure parameter block. (4-bytes)
Required Free Memory The minimum number of free bytes the Search Procedure code resource needs in its own heap to make local allocation of memory using Macintosh OS/Toolbox routines. Enter 0 (zero) to not create a sub-heap and run inside the Installer’s heap. Please see warnings about using sub-heaps in the Atom Extender section if you specify a value other than 0. (4-bytes)
Search Procedure Summary
An optional string briefly describing the purpose of this Search Procedure. This string is never displayed to the user. (even-padded Pascal string)
About the Disk Order Resource (‘indo’)
By default, the Installer requests disks from the user using the order of the atoms specified in the script. This ordering is displayed in the status dialog. With more than just a few atoms, it can be very difficult to control the order of disks. To make this easier, if an Installer Disk Order resource exists in the script (resource type 'indo'), this resource is used to determine the ordering of the disks. The format of the 'indo' resource is given below. The resource contains a list of Pascal strings that are the names of the source disks. These names must exactly match the names of the volumes given in the source and target paths within the File Specs.
For example, let’s say you have created a two disk set that uses one floppy disk and one CD volume. Your ‘indo’ might look like this:
resource 'indo' (1000) {
format1 {{
kExpectFloppyDisk,
"Installer Disk",
kExpectCDVolume,
"Applications CD"
}};
};
Specifying the expected type of source disk just helps the Installer know which type of disk drive to make available to insert the requested source disk. This feature does not affect the user’s ability to create network installation folders on an AppleShare server volume.
Disk Order Reference
Resource Description
Format 0 of the new ‘indo’ resource:
#define SrcDiskType \
integer \
kExpectFloppyDisk = 0, /* It’s a floppy Disk */ \
kExpectCDVolume = 1, /* It’s a CD */ \
kExpectFoldersOnVol = 2 /* It’s a folder */
type 'indo' {
switch {
case format1:
key integer = 1;
integer = $$Countof(SrcVolArray);
array SrcVolArray {
SrcDiskType; /* Source Disk Type */
evenPaddedString; /* Source Disk Name */
};
};
};
Field descriptions
Source Disk Type The expected source disk type. Currently, a floppy disk; CD or folders on a CD, HD, or AppleShare volume. The Installer primarily uses this information to determine which type of disk to eject to make room for the requested source disk. For example, if the requested source disk is expected to be a CD and all CD drives are full, then one of the CDs will be ejected. (2-bytes)
Source Disk Name The name of the source disk. The name can end in a colon if you wish. (2-bytes)
Installer Functions
This chapter describes the routines that are available when running as an external code resource within the Installer environment.
About Installer Functions
Installer functions allow the code resource writer to communicate with the Installer and use utility routines provided by the Installer. Some of the routines are the essential mechanism for communicating with the Installer, such as when decompressing files during installation. These routines are often limited to being called from specific code resources. Other routines may be available all the time, either as a means to getting information from the Installer or as helpful utility routines.
All Installer callback functions are actually glue routines that you must include in your code to access the proper routines inside the Installer. In the discussion of each routine the name of the header file and glue file is mentioned.
Data I/O Routines
This section describes the routines available to manage reading and writing atom data. Most of these routines are only available in Atom Extenders. These routines function very similar to high-level File Manager routines. Consult Inside Macintosh: File s for an overview of topics such as positioning marks in files.
count The number of bytes to read from the source data. After the call, the actual number of bytes read is returned in count.
bufferPtr A pointer to a buffer of at least size count.
DESCRIPTION
The ReadSourceData function reads the specified number of bytes from the source data beginning at the current position. The supplied pointer must have already been allocated to at least the size of count.
See interface file “AtomExtenderHeader.h” and glue code file “AtomExtenderCBGlue.c”.
RESULT CODES
kNotImplementedErr 30901 Routine not currently implemented
count The number of bytes to write to the target at the current position.
bufferPtr A pointer to a buffer of at least size count.
DESCRIPTION
The WriteTargetData function writes the specified number of bytes from the supplied buffer to the target beginning at the current position. The data is not immediately written to the target file, but rather is buffered using the Installer heap or MultiFinder temporary memory. This reduces our need for the target disk, which is especially important when installing onto floppy disks.
IMPORTANT
Since there is overhead associated with each call to WriteTargetData, calls to write very small amounts of data (less than 1K) should be avoided.
See interface file “AtomExtenderHeader.h” and glue code file “AtomExtenderCBGlue.c”.
RESULT CODES
kNotImplementedErr 30901 Routine not currently implemented
count The number of bytes to read from the target data. After the call, the actual number of bytes read is returned in count.
bufferPtr A pointer to a buffer of at least size count.
DESCRIPTION
The ReadTargetData function reads the specified number of bytes from the target data beginning at the current position. The supplied pointer must have already been allocated to at least the size of count.
IMPORTANT
The ReadTargetData function can only be called while in a Version Compare code resource that was referenced from a Resource Atom. Calling this function at any other time will return a kNotImplementedErr error.
See interface file “AtomExtenderHeader.h” and glue code file “AtomExtenderCBGlue.c”.
RESULT CODES
kNotImplementedErr 30901 Routine not currently implemented
theLength On output, contains the length of the source data.
DESCRIPTION
The GetSourceDataPos function returns the length of the source data.
See interface file “AtomExtenderHeader.h” and glue code file “AtomExtenderCBGlue.c”.
RESULT CODES
kNotImplementedErr 30901 Routine not currently implemented
noErr 0 No error
Memory Routines
This section describes the routines available to manage static memory. Some code resources can pass back a handle to static memory so the code resource can communicate between invocations of the code resource. Generally, these routines are available all the time.
newHandleSize The requested size to allocate the handle.
DESCRIPTION
The INewHandle function attempts to allocate a handle of the specified size. If the memory is not immediately available, the Installer writes out any buffered target data to the appropriate target disk, then tries again. The resulting handle is NULL if the handle could not be allocated.
Use INewHandle when you want to pass information between invocations of an Atom Extender using the fStaticDataHandle of the parameter block.
See interface file “InstallerMemoryFuncsHeader.h” and glue code file “InstallerMemoryCBGlue.c”.
IMPORTANT
Always use IDisposHandle to release a handle allocated using INewHandle. Always use IHLock and IHUnLock when locking and unlocking a handle allocated using INewHandle.
RESULT CODES
kNotImplementedErr 30901 Routine not currently implemented
noErr 0 No error
memFullErr -108 Not enough room in the Installer’s or MultiFinder’s heap zone
The IDisposHandle function disposes the handle in the parameter storageHandle. The handle could have been allocated using the Installer’s INewHandle function, or with any other Macintosh Toolbox routine.
See interface file “InstallerMemoryFuncsHeader.h” and glue code file “InstallerMemoryCBGlue.c”.
RESULT CODES
kNotImplementedErr 30901 Routine not currently implemented
noErr 0 No error
nilHandleErr -109 NULL master pointer
memWZErr -111 Attempt to operate on a free block
IHLock
void IHLock( CallBackProcPtr pCallBackProcPtr,
Handle storageHandle );
pCallBackProcPtr The callback pointer.
storageHandle The handle to lock.
DESCRIPTION
The IHLock function locks the specified handle.
See interface file “InstallerMemoryFuncsHeader.h” and glue code file “InstallerMemoryCBGlue.c”.
IMPORTANT
Always use IHLock to lock a handle allocated using INewHandle.
RESULT CODES
kNotImplementedErr 30901 Routine not currently implemented
noErr 0 No error
nilHandleErr -109 NULL master pointer
memWZErr -111 Attempt to operate on a free block
IHUnLock
void IHUnLock( CallBackProcPtr pCallBackProcPtr,
Handle storageHandle );
pCallBackProcPtr The callback pointer.
storageHandle The handle to lock.
DESCRIPTION
The IHUnLock function unlocks the specified handle.
See interface file “InstallerMemoryFuncsHeader.h” and glue code file “InstallerMemoryCBGlue.c”.
IMPORTANT
Always use IHUnLock to unlock a handle allocated using INewHandle.
RESULT CODES
kNotImplementedErr 30901 Routine not currently implemented
noErr 0 No error
nilHandleErr -109 NULL master pointer
memWZErr -111 Attempt to operate on a free block
Misc. Routines
This section describes various miscellaneous routines available.
param0…param3 A pointer to data or 4-byte value used to send information to the Action Handler about the action.
resultPtr A pointer to a variable that the Action Handler can send information back to the caller. The format of the data structure is defined individually for those actions that allow modification to the result.
DESCRIPTION
The RegisterScriptAction function registers an action with the Installer, which will be immediately given to all loaded Action Handlers. This function is made available to help code resource writers easily send text messages to the Installer Debugger, using the action class kDebuggingAction, and the action identifier kGenericDebugActID.
See interface file “ActionHandlerHeader.h” and glue code file “ActionHanderCBGlue.c”.
IMPORTANT
RegisterScriptAction cannot be called from within an ActionHandler code resource.
Calling the SuspendWaitCursor function stops the wait cursor and returns the cursor to an arrow. Use the ResumeWaitCursor to begin the wait cursor again. This is handy if you want to show a dialog from a code resource during the installation.
See interface file “ActionAtomHeader.h” and glue code file “ActionAtomCBGlue.c”.
Calling the IncrementStatusBar function increments the status bar during long waits inside your code resource. Most often you’ll use this in your Action Atom code resource. Upon entry to your Action Atom you are given 100 status increments to use to show progress while executing a single Action Atom. The Installer limits the bar so you don’t have to worry about incrementing the bar too far.
See interface file “ActionAtomHeader.h” and glue code file “ActionAtomCBGlue.c”.
Miscellaneous Features
This chapter describes miscellaneous features of Installer 4.0 available to scriptwriters.
About Action Handlers
Action Handlers allow external code resources to be called in response to specific actions in a “debug” version of the Installer. An action might provide information about which files will be replaced during the installation, the reason the script cannot be read, the outcome of Easy Install or Custom Install rule evaluation, or why the installation failed.
The Action Handler code resource should be located in the script file. A “debug” version of the Installer is available that has the necessary code to look for and send actions to all Action Handlers found in the Installer application file and script file.
Apple supplies an Installer Debugger implemented as an Action Handler. Scriptwriters can write other Action Handlers as needed.
Writing an Action Handler
When the Installer first finds and opens the Installer script file it looks for all resources in the script and Installer file with the type ‘inah’. The ‘inah’ resource contains the type and ID is of the actual Action Handler code resource. Each of the code resources are loaded into the Installer’s heap and detached.
An Installer action consists of an action class ID and an action identifier. When a loggable action occurs in the Installer, each Action Handler code resource is called with a pointer to a Action Handler parameter block. Action Handlers will be called in order of their resource ID (‘inah’ rsrc ID ). When called the Action Handler can handle the action however it desires, but remember that other Action Handlers may be called before and after yours. Depending on the action the Action Handler may be able to modify the result value to effect the progress of the Installer, such as when evaluating rules.
The Action Handler receives an initialize action when the script is first opened, and a close action when the Installer quits. Action Handlers can use the initialize action to allocate persistent memory to communicate between invocations of the same Action Handler. The Action Handler also receives all events that pass through the Installer.
Action Handler Runtime Environment
During execution the Action Handler shares memory space with the Installer. Local memory allocation using Memory Manager calls will come from the Installer’s heap. Action Handlers should use the Installer’s INewHandle routine to allocate memory that it wishes to persist between calls to the Action Handler.
Action Handler Reference
This section describes the data structures, resource descriptions and defined actions needed to use or write Action Handlers.
Data Structures
This section describes the function prototype, parameter block structure and defined actions.
Function Interface
The Installer calls your Action Handler code resource assuming the following function declaration.
long HandleAction( ActionHandlerPBPtr theActionHandlerPB );
The Action Handler writer should look at the actionClassID and actionIdentifier to determine how to react to the action. The four parameters, fParam0, fParam1, fParam2 and fParam3 will contain additional information depending on the action. You’ll need to include either “ActionHandlerHeader.h” or “ActionHandlerHeader.p” to allow access to the defined action class IDs and action identifiers.
Parameter Block
The Installer calls your Action Handler code resource, passing it the following parameter block.
typedef struct{
<-> Handle fStaticDataHdl;
—> ProcPtr fCallBackProcPtr;
—> short fTargetVRefNum;
—> long fTargetFolderDirID;
—> short fSystemVRefNum;
—> long fSystemBlessedDirID;
-> short fActionClassID;
-> short fActionIdentifier;
-> void* fParam0;
-> void* fParam1;
-> void* fParam2;
-> void* fParam3;
-> void* fResultPtr;
} ActionHandlerPB, *ActionHandlerPBPtr;
Field descriptions
fStaticDataHdl A handle created by the Action Handler using INewHandle to save information between calls to this Action Handler code resource. The field is always NULL when your Action Handler is initialized. You can assign a value to this field during any call to the Action Handler, and receive the same value in this field during the next action.
fCallBackProcPtr A pointer to the Installer’s dispatch routine. You’ll need to pass this field as a parameter to Installer function glue routines.
fTargetVRefNum The target disk’s vRefNum. When allowing the user to select a target application folder, this is the volume on which the folder resides.
fTargetFolderDirID The target application folder’s directory ID. This value is -1 if the user cannot select a target application folder. Target File Specs that use the reserved folder path folder-user will be placed in this folder.
fSystemVRefNum The system disk’s vRefNum. Target File Specs that use the reserved folder path special-xxx will be placed in the System Folder on this volume.
fSystemBlessedDirID The directory ID of the System Folder on the disk with the refNum fSystemVRefNum. This directory is not necessarily the currently active System Folder.
fActionClassID The action’s class ID (i.e. a script error.). Available class IDs are defined in “ActionHandlerHeader.h” and “ActionHandlerHeader.p”.
fActionIdentifier The action’s identifier (i.e. couldn’t find script resource.). Available identifiers are defined in “ActionHandlerHeader.h” and “ActionHandlerHeader.p”.
fParam0..fParam3 Parameters containing extra information for the action. Contents of the parameters are defined in “ActionHandlerHeader.h” and “ActionHandlerHeader.p” for each action.
fResultPtr A pointer to the result variable. This is used by some actions to enable the Action Handler to change the result, such as with rules and rule clauses.
Actions
The following is listing of the current actions supported by the Installer. See the file “ActionHandlerHeader.h” file for a complete description of all actions.
Action Class: kDebuggingAction
kInitializationActID
kCloseActID
kStdEventActID
kGenericDebugActID
Action Class: kScriptAction
kPackageNotFoundActID
kAtomNotFoundInPackageActID
kFrameworkNotFoundActID
kRuleNotFoundActID
kFileSpecNotFoundActID
kFileSpecIsBadActID
kCouldNotOpenScriptActID
kFileSpecIDIsBadActID
kAtomIDIsBadActID
kNotEnoughMemoryToReadActID
kSubHeapToSmallActID
kFileSpecNotFndWithRefActID
kVersCompareNotFoundActID
kSearchProcNotFoundActID
kRuleFunctionNotFoundActID
Action Class: kFireRulesAction
kFrameworkActID
kRuleResultActID
kRuleClauseResultActID
Action Class: kTargetAction
kTgtFileNotFoundActID
kTgtFileLockedActID
kTgtErrForFileAtomActID
kTgtErrForRsrcAtomActID
kTgtErrForFontAtomActID
kTgtMatchesSrcErrActID
Action Class: kSourceAction
kSrcFileNotFoundActID
kSrcErrForFileAtomActID
kSrcErrForRsrcAtomActID
kSrcErrForFontAtomActID
kSrcErrForFolderAtomActID
kSrcErrForResMergeAtomActID
Action Class: kExtenderAction
kExtCodeRsrcNotFoundActID
kExtenderRsrcNotFoundActID
kCallBackNotAvailableActID
kExtenderResultActID
kA5NotSetCorrectlyActID
kTgtSetupProcNotFoundActID
kVersCodeRsrcNotFoundActID
kActionAtomCodeRsrcNFActID
kSearchProcCodeRsrcNFActID
kSearchProcBadFileActID
kRuleFuncCodeRsrcNFActID
kLowModuleSetupMemoryActID
kNoModuleSetupMemoryActID
Action Class: kProgressAction
kClickedInstallActID
kClickedRemoveActID
kInstallationResultActID
kRemovalResultActID
kActionAtomResultActID
Action Class: kFileProgressAction
kFileCopiedID
kFileNotCopiedID
kFileNotCopiedNewerLeftID
kFileNotCopiedLockedID
kFileUpdatedID
kFileNotUpdatedKeptExistID
kFileNotUpdatedNotExistID
kFileRemovedID
kFileNotRemovedID
kFileNotRemovedNoExistID
kFileNotRemovedLockedID
kFileSetLockedID
Action Class: kRsrcProgressAction
kRsrcCopiedID
kRsrcNotCopiedID
kRsrcNotCopiedNewerLeftID
kRsrcNotCopiedNotTargetID
kRsrcNotCopiedProtectedID
kRsrcUpdatedID
kRsrcNotUpdatedKeptExistID
kRsrcNotUpdatedLockedID
kRsrcNotUpdatedNotExistID
kRsrcNotUpdatedProtectedID
kRsrcRemovedID
kRsrcNotRemovedID
kRsrcNotRemovedNoExistID
kRsrcNotRemovedProtectedID
kRsrcNotRemovedLockedID
Action Class: kFontProgressAction
kFontCopiedID
kFontNotCopiedID
kFontUpdatedID
kFontNotUpdatedKeptExistID
kFontNotUpdatedLockedID
kFontNotUpdatedNotExistID
kFontNotUpdatedProtectedID
kFontRemovedID
kFontNotRemovedID
kFontNotRemovedNoExistID
kFontNotRemovedLockedID
kFontNotRemovedProtectedID
Action Class: kFolderProgressAction
kFolderCopiedID
Action Class: kResMergeProgressAction
kResMergeCopiedID
Resource Description
The template of the Action Handler resource is shown below.
Action Handler Flags Currently reserved for use by Apple Computer, Inc. (2-bytes)
Action Handler Code Rsrc Type
The resource type of the Action Handler code resource. (4-bytes)
Action Handler Code Rsrc ID
The resource ID of the Action Handler code resource. (2-bytes)
Minimal Required Memory The minimum number of free bytes the Action Handler code resource needs during execution. (4-bytes)
Handler Summary An optional string briefly describing what this Action Handler does. This string is never displayed to the user. (even-padded Pascal string)
About the Installer Version Resource (‘invs’)
You may want to ensure that the version of the Installer that you used for development and testing and that you shipped is the one that is launched. To do so, add an 'invs' Installer Version resource to specify the specific Installer version needed for your script. If you require Installer 4.0 and a different version is launched and the version specified in this resource is 4.0 then the Installer will display a dialog saying something like “The Installer document [your document's name here] requires version [invs version number here] of the Installer application. Try opening the Installer application that is in the same folder as this Installer document.”
The Installer uses the four hex bytes that specify the version number to compare against its own version. The string is used only in the dialog that is displayed when the two versions do not match.
The following is an example 'invs' resource for Installer 4.0.3.
resource 'invs' (1) {
format0 {
0x4,
0x03,
release,
0x0,
"4.0.3"
}
};
Installer Version Reference
Resource Description
Format 0 of the ‘invs’ resource:
type 'invs' {
switch {
case format0:
key integer = 0;
hex byte; /* Major revision in BCD */
hex byte; /* Minor revision in BCD */
hex byte; /* Release Stage */
hex byte; /* Release Number */
pstring; /* Short Version Number String */
};
};
Field descriptions
Major Revision The major version number. (2-bytes)
Minor Revision The minor version number. (2-bytes)
Release Stage The release stage. Four release stage constants are defined in the InstallerTypes.r file: development, alpha, beta, final and release. (2-bytes)
Release Number The release number. (2-bytes)
Short Version Number String
Text description of version number. (even-padded Pascal string)
About the Script Size Resource (‘insz’)
Use of the new script resource, ‘insz’ with an ID of 1 is recommend for scripts over 10K in size. When the script resources are loaded into memory, they actually go into a sub-heap inside of the Installer’s main heap. This improves Memory Manager performance on older machines. In previous versions of the Installer, the size of this sub-heap was always overestimated to account for possibly compressed resources in the script file. This older scheme has the potential for wasting precious Installer heap memory, requiring a larger application partition.
ScriptCheck 4.0 calculates this value and automatically places this resource into your script. The size calculated is calculated using the following script resource types: 'inaa', 'infa', 'inra', 'inff', 'inrm', 'intf', infs', 'inpk', 'inrl', 'infr', 'inex', 'invc', 'insp', 'inat', 'inbb', 'indo', incd', 'insz', 'icmt', 'inpc', 'inr#'.
Script Size Reference
Resource Description
Format 0 of the ‘invs’ resource:
type 'insz' {
switch {
case format0:
key integer = 0; /* Format version */
unsigned longint; /* Script Sub-Heap Size in bytes */
};
};
Field descriptions
Script Sub-Heap Size The size in bytes the script resources will require when loaded into memory. This value is used to create an optimally sized sub-heap for the Installer script resources. (4-bytes)
About the Script Creation Date Resource (‘incd’)
The script creation date resource holds a copy of the script file’s creation date field. This value is used by the Installer to correctly find and verify the source files when copied to an AppleShare server. Because the creation date of the source files may have been changed during the copy, the Installer uses the creation date in the ‘incd’ resource to calculate a delta value using the script’s creation date stored in the file by the File Manager. Without this resource, the user may get an error after beginning the installation saying that the source files could not be found.
ScriptCheck automatically updates or adds this resource to your script.
Script Creation Date Reference
Resource Description
The ‘incd’ resource:
type 'incd' {
unsigned longint; /* Script Creation Date in seconds. */
};
};
Field descriptions
Script Creation Date The original creation date in seconds of the script file. (4-bytes)
Installation Topics
This chapter discusses information that may help some scriptwriters keep out of trouble and provide solutions to unique situations.
Installing Desk Accessories
Installing into Pre-7.X Systems
Desk Accessories are installed into the System file as 'DRVR' resources. The installer will take care of all of the DA's owned resources. Following is an example of a resource atom used to install a desk accessory. Flags with the comment /* your choice */ can be either value.
resource 'inra' (raDAtoInstall) {
format0 {
deleteWhenRemoving, /* your choice */
deleteWhenInstalling, /* remove the outdated DA */
copy, /* Copy rsrc to destination */
tgtRequired, /* Target file need already exist to install */
updateExisting, /* your choice */
copyIfNewOrUpdate, /* your choice */
ignoreProtection, /* your choice */
srcNeedExist, /* Rsrc needs to exist on source disk */
fsSourceDA, /* Source file spec where to get rsrc */
'DRVR', /* Resource type */
0, /* Resource source id (must be 0) */
0, /* Resource target id (must be 0) */
0, /* atom size (filled in by ScriptCheck) */
"Desk Accessory: DA name", /* Atom description */
"\0x00DA Name" /* Resource name */
};
};
When installing DA's into System 6.0.x and prior, use the 'deleteWhenInstalling' flag in conjunction with the 'updateExisting' flag. In general, always use the 'deleteWhenInstalling' option when using the 'updateExisting' flag. Conversely, use the 'dontDeleteWhenInstalling' flag with the 'keepExisting' flag.
Installing into System 7.X
Desk Accessories are installed into the Apple Menu Items Folder that is found in the System Folder. Each Desk Accessory is contained in a single file. Use a typical 'infa' to install your DA.
Glossary
buffering The act of storing up atom data to be written to the target disk later in the installation. This reduces the Installer’s need for the target disk, in case the disk is ejectable.
folder-user A reserved target pathname used in target file specs to specify the user-selected application folder.
“live” installation An installation where a file in the currently active System Folder will be deleted or modified. This type of installation always requires that all other applications are quit before beginning the installation. The original file is never touched, and is saved to provide for cancellation of the installation.
part The portion of atom data that is given to an Atom Extender during a kBeforePart and kAfterPart message. May or may not be the same as the source piece.
preflighting The tasks performed after the user clicks the “Install” button and before the status dialog appears. Some of the tasks performed are: checking for locked files, checking for protected resources, calculating required target disk space, and checking if a target file equates to a source file.
special-xxxx A reserved target pathname used in target file specs to specify a special folder, usually a folder in the System Folder. The name of the folder is found in a ‘fld#’ resource using the folder type ( where ‘xxxx’ is the type of the folder).
source pieces The portions of atom data on the source disk that will be combined during the installation to create the target data. For example, a large file is split into three files so they will fit onto floppy disks. Each of the three files would be considered a source piece.
strike The combination of size and style of a font.